public static string GetLastMessage() { PhpSqlDbConnection last_connection = (PhpSqlDbConnection)manager.GetLastConnection(); if (last_connection == null) { return(failConnectErrorMessage); } return(last_connection.GetLastErrorMessage()); }
public static int GetLastAffectedRows(PhpResource linkIdentifier) { PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier); if (connection == null) { return(-1); } return(connection.LastAffectedRows); }
public static bool SelectDb(string databaseName, PhpResource linkIdentifier) { PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier); if (connection == null) { return(false); } return(connection.SelectDb(databaseName)); }
/// <summary> /// Validates whether the specified handler is instance of PhpDbConnection type. /// </summary> /// <param name="handle"></param> /// <returns></returns> internal static PhpSqlDbConnection ValidConnection(PhpResource handle) { PhpSqlDbConnection connection = handle as PhpSqlDbConnection; if (connection != null && connection.IsValid) { return(connection); } PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_connection_resource")); return(null); }
public static bool Close(PhpResource linkIdentifier) { var connection = PhpSqlDbConnection.ValidConnection(linkIdentifier); if (connection == null) { return(false); } GetManager().RemoveConnection(connection); connection.Close(); return(true); }
private static PhpResource Connect(string server, string user, string password, bool newLink, bool persistent) { // persistent connections are treated as transient, a warning is issued: if (persistent) { PhpException.FunctionNotSupported(PhpError.Notice); } MsSqlLocalConfig local = MsSqlConfiguration.Local; MsSqlGlobalConfig global = MsSqlConfiguration.Global; StringBuilder opts = new StringBuilder(); if (local.ConnectTimeout > 0) { opts.AppendFormat("Connect Timeout={0}", local.ConnectTimeout); } if (global.NTAuthentication) { if (opts.Length > 0) { opts.Append(';'); } user = password = null; opts.Append("Integrated Security=true"); } string connection_string = PhpSqlDbConnection.BuildConnectionString(server, user, password, opts.ToString()); bool success; PhpSqlDbConnection connection = (PhpSqlDbConnection)GetManager().OpenConnection(connection_string, newLink, global.MaxConnections, out success); if (!success) { if (connection != null) { UpdateConnectErrorInfo(connection); connection = null; } return(null); } return(connection); }
public static PhpResource CreateProcedure(string procedureName, PhpResource linkIdentifier) { PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier); if (connection == null) { return(null); } if (procedureName == null) { PhpException.ArgumentNull("procedureName"); return(null); } return(new PhpSqlDbProcedure(connection, procedureName)); }
public static PhpResource Query(string query, PhpResource linkIdentifier, int batchSize) { PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier); if (query == null || connection == null) { return(null); } PhpSqlDbResult result = (PhpSqlDbResult)connection.ExecuteQuery(query.Trim(), true); if (result == null) { return(null); } result.BatchSize = batchSize; return(result); }
private static void UpdateConnectErrorInfo(PhpSqlDbConnection connection) { failConnectErrorMessage = connection.GetLastErrorMessage(); }
private static void UpdateConnectErrorInfo(PhpSqlDbConnection connection) { GetManager(connection.ScriptContext) .FailConnectErrorMessage = connection.GetLastErrorMessage(); }