public static PhpResource mssql_init(Context ctx, string procedureName, PhpResource linkIdentifier) { PhpSqlDbConnection connection = ValidConnection(ctx, linkIdentifier); if (connection == null) { return(null); } if (procedureName == null) { PhpException.ArgumentNull("procedureName"); return(null); } return(new PhpSqlDbProcedure(connection, procedureName)); }
static PhpResource Connect(Context ctx, string server, string user, string password, bool newLink, bool persistent) { if (persistent) { // persistent connections are treated as transient, a warning is issued: PhpException.FunctionNotSupported("mssql_pconnect"); } var config = ctx.Configuration.Get <MsSqlConfiguration>(); var opts = new StringBuilder(); if (config.ConnectTimeout > 0) { opts.AppendFormat("Connect Timeout={0}", config.ConnectTimeout); } if (config.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 = GetManager(ctx).CreateConnection(connection_string, newLink, config.MaxConnections, out success); if (!success) { if (connection != null) { UpdateConnectErrorInfo(ctx, connection); connection = null; } return(null); } return(connection); }
static void UpdateConnectErrorInfo(Context ctx, PhpSqlDbConnection connection) { GetManager(ctx).FailConnectErrorMessage = connection.GetLastErrorMessage(); }