示例#1
0
文件: MsSql.cs 项目: jiahao42/weverca
        public static string GetLastMessage()
        {
            PhpSqlDbConnection last_connection = (PhpSqlDbConnection)manager.GetLastConnection();

            if (last_connection == null)
            {
                return(failConnectErrorMessage);
            }

            return(last_connection.GetLastErrorMessage());
        }
示例#2
0
        public static int GetLastAffectedRows(PhpResource linkIdentifier)
        {
            PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier);

            if (connection == null)
            {
                return(-1);
            }

            return(connection.LastAffectedRows);
        }
示例#3
0
        public static bool SelectDb(string databaseName, PhpResource linkIdentifier)
        {
            PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier);

            if (connection == null)
            {
                return(false);
            }

            return(connection.SelectDb(databaseName));
        }
示例#4
0
        /// <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);
        }
示例#5
0
        public static bool Close(PhpResource linkIdentifier)
        {
            var connection = PhpSqlDbConnection.ValidConnection(linkIdentifier);

            if (connection == null)
            {
                return(false);
            }

            GetManager().RemoveConnection(connection);

            connection.Close();
            return(true);
        }
示例#6
0
        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);
        }
示例#7
0
        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));
        }
示例#8
0
        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);
        }
示例#9
0
		private static void UpdateConnectErrorInfo(PhpSqlDbConnection connection)
		{
			failConnectErrorMessage = connection.GetLastErrorMessage();
		}
示例#10
0
 private static void UpdateConnectErrorInfo(PhpSqlDbConnection connection)
 {
     GetManager(connection.ScriptContext)
     .FailConnectErrorMessage = connection.GetLastErrorMessage();
 }
示例#11
0
文件: MsSql.cs 项目: dw4dev/Phalanger
		private static void UpdateConnectErrorInfo(PhpSqlDbConnection connection)
		{
            GetManager(connection.ScriptContext)
                .FailConnectErrorMessage = connection.GetLastErrorMessage();
		}
示例#12
0
文件: MsSql.cs 项目: jiahao42/weverca
 private static void UpdateConnectErrorInfo(PhpSqlDbConnection connection)
 {
     failConnectErrorMessage = connection.GetLastErrorMessage();
 }