Beispiel #1
0
 public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
 {
     var cmd = pdo.PDOConnection.LastCommand;
     if (cmd is MySqlCommand)
         return ((MySqlCommand)cmd).LastInsertedId;
     else
         return false;
 }
Beispiel #2
0
 public override object GetLastInsertId(Core.ScriptContext context, PDO pdo, string name)
 {
     using (var com = ((SqlConnection)pdo.Connection).CreateCommand())
     {
         com.Transaction = (SqlTransaction)pdo.Transaction;
         com.CommandText = "SELECT @@IDENTITY";
         return(com.ExecuteScalar());
     }
 }
Beispiel #3
0
 public override object GetLastInsertId(Core.ScriptContext context, PDO pdo, string name)
 {
     using (var com = ((SqlConnection)pdo.Connection).CreateCommand())
     {
         com.Transaction = (SqlTransaction)pdo.Transaction;
         com.CommandText = "SELECT @@IDENTITY";
         return com.ExecuteScalar();
     }
 }
Beispiel #4
0
        public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
        {
            MySqlConnection con = (MySqlConnection)pdo.Connection;

            using (var com = con.CreateCommand())
            {
                com.CommandText = "SELECT LAST_INSERT_ID()";
                com.Transaction = (MySqlTransaction)pdo.Transaction;
                return(com.ExecuteScalar());
            }
        }
Beispiel #5
0
        public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
        {
            var cmd = pdo.PDOConnection.LastCommand;

            if (cmd is MySqlCommand)
            {
                return(((MySqlCommand)cmd).LastInsertedId);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
 public abstract PDOStatement CreateStatement(ScriptContext context, PDO pdo);
Beispiel #7
0
 public abstract object GetLastInsertId(ScriptContext context, PDO pdo, string name);
Beispiel #8
0
 public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
 {
     return ((SQLiteConnection)pdo.Connection).LastInsertRowId;
 }
Beispiel #9
0
 public override PDOStatement CreateStatement(ScriptContext context, PDO pdo)
 {
     SQLitePDOStatement stmt = new SQLitePDOStatement(context, pdo);
     return stmt;
 }
Beispiel #10
0
 public abstract object GetLastInsertId(ScriptContext context, PDO pdo, string name);
Beispiel #11
0
 public PDOStatement(ScriptContext context, PDO pdo)
     : base(context, true)
 {
     this.m_pdo = pdo;
     this.setFetchMode(context, (int)PDOFetchType.PDO_FETCH_BOTH, null, null);
 }
Beispiel #12
0
 public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
 {
     return(((SQLiteConnection)pdo.Connection).LastInsertRowId);
 }
Beispiel #13
0
 internal SQLitePDOStatement(ScriptContext context, PDO pdo)
     : base(context, pdo)
 {
     this.m_com = (SQLiteCommand)pdo.Connection.CreateCommand();
 }
Beispiel #14
0
 public override PDOStatement CreateStatement(Core.ScriptContext context, PDO pdo)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
        public override System.Data.IDbConnection OpenConnection(ScriptContext context, string dsn_data, string username, string password, object argdriver_options)
        {
            var opt = PDO.SplitDsnParams(dsn_data);

            MySqlConnectionStringBuilder msb = new MySqlConnectionStringBuilder();

            foreach (string key in opt.Keys)
            {
                string value = opt[key];
                switch (key)
                {
                case "host": msb.Server = value; break;

                case "port": msb.Port = uint.Parse(value); break;

                case "db_name": msb.Database = value; break;

                case "unix_socket": throw new NotSupportedException(); break;

                case "charset": msb.CharacterSet = value; break;

                default:
                    throw new NotSupportedException();
                }
            }
            if (!string.IsNullOrEmpty(username))
            {
                msb.UserID = username;
            }
            if (!string.IsNullOrEmpty(password))
            {
                msb.Password = password;
            }
            if (argdriver_options is PhpArray)
            {
                PhpArray optArr = (PhpArray)argdriver_options;
                foreach (var key in optArr.Keys)
                {
                    if (key.IsInteger)
                    {
                        object value = optArr[key];
                        switch (key.Integer)
                        {
                        case MYSQL_ATTR_USE_BUFFERED_QUERY: break;

                        case MYSQL_ATTR_INIT_COMMAND: break;

                        case MYSQL_ATTR_READ_DEFAULT_FILE: break;

                        case MYSQL_ATTR_READ_DEFAULT_GROUP: break;

                        case MYSQL_ATTR_MAX_BUFFER_SIZE: break;

                        case MYSQL_ATTR_DIRECT_QUERY: break;

                        case MYSQL_ATTR_FOUND_ROWS: msb.UseAffectedRows = PHP.Core.Convert.ObjectToBoolean(value); break;

                        case MYSQL_ATTR_IGNORE_SPACE: break;

                        case MYSQL_ATTR_COMPRESS: msb.UseCompression = PHP.Core.Convert.ObjectToBoolean(value); break;

                        case MYSQL_ATTR_SSL_CA: break;

                        case MYSQL_ATTR_SSL_CAPATH: break;

                        case MYSQL_ATTR_SSL_CERT: msb.CertificateFile = PHP.Core.Convert.ObjectToString(value); break;

                        case MYSQL_ATTR_CIPHER: break;

                        case MYSQL_ATTR_KEY: msb.CertificatePassword = System.IO.File.ReadAllText(PHP.Core.Convert.ObjectToString(value)); break;

                        default:
                            throw new NotSupportedException();
                        }
                    }
                }
            }

            MySqlConnection con   = new MySqlConnection(msb.ConnectionString);
            Action          clear = null;

            clear = () =>
            {
                con.Dispose();
                RequestContext.RequestEnd -= clear;
            };
            RequestContext.RequestEnd += clear;
            con.Open();

            return(con);
        }
Beispiel #16
0
 internal SQLitePDOStatement(ScriptContext context, PDO pdo)
     : base(context, pdo)
 {
     this.m_com = (SQLiteCommand)pdo.Connection.CreateCommand();
 }
Beispiel #17
0
 public PDOStatement(ScriptContext context, PDO pdo)
     : base(context, true)
 {
     this.m_pdo = pdo;
     this.setFetchMode(context, (int)PDOFetchType.PDO_FETCH_BOTH, null, null);
 }
Beispiel #18
0
 internal MySQLPDOStatement(ScriptContext context, PDO pdo)
     : base(context, pdo)
 {
     pdo.PDOConnection.LastCommand = this.m_com = (MySqlCommand)pdo.Connection.CreateCommand();
 }
Beispiel #19
0
        /// <summary>
        /// Creates new PDO statement.
        /// </summary>
        public override PDOStatement CreateStatement(ScriptContext context, PDO pdo)
        {
            MySQLPDOStatement stmt = new MySQLPDOStatement(context, pdo);

            return(stmt);
        }
Beispiel #20
0
 public abstract PDOStatement CreateStatement(ScriptContext context, PDO pdo);
Beispiel #21
0
 public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
 {
     MySqlConnection con = (MySqlConnection)pdo.Connection;
     using (var com = con.CreateCommand())
     {
         com.CommandText = "SELECT LAST_INSERT_ID()";
         com.Transaction = (MySqlTransaction)pdo.Transaction;
         return com.ExecuteScalar();
     }
 }
Beispiel #22
0
 public override PDOStatement CreateStatement(Core.ScriptContext context, PDO pdo)
 {
     throw new NotImplementedException();
 }