/// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOMySQLConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new MySQLPDODriver());

            string fullname = typeof(PDO).Name;
            var    tPDO     = ApplicationContext.Default.GetType(new QualifiedName(new Name(typeof(PDO).FullName)), ref fullname);

            Core.Reflection.PhpMemberAttributes att = Core.Reflection.PhpMemberAttributes.Public | Core.Reflection.PhpMemberAttributes.Static;
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_USE_BUFFERED_QUERY", MySQLPDODriver.MYSQL_ATTR_USE_BUFFERED_QUERY);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_INIT_COMMAND", MySQLPDODriver.MYSQL_ATTR_INIT_COMMAND);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_READ_DEFAULT_FILE", MySQLPDODriver.MYSQL_ATTR_READ_DEFAULT_FILE);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_READ_DEFAULT_GROUP", MySQLPDODriver.MYSQL_ATTR_READ_DEFAULT_GROUP);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_MAX_BUFFER_SIZE", MySQLPDODriver.MYSQL_ATTR_MAX_BUFFER_SIZE);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_DIRECT_QUERY", MySQLPDODriver.MYSQL_ATTR_DIRECT_QUERY);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_FOUND_ROWS", MySQLPDODriver.MYSQL_ATTR_FOUND_ROWS);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_IGNORE_SPACE", MySQLPDODriver.MYSQL_ATTR_IGNORE_SPACE);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_COMPRESS", MySQLPDODriver.MYSQL_ATTR_COMPRESS);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_SSL_CA", MySQLPDODriver.MYSQL_ATTR_SSL_CA);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_SSL_CAPATH", MySQLPDODriver.MYSQL_ATTR_SSL_CAPATH);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_SSL_CERT", MySQLPDODriver.MYSQL_ATTR_SSL_CERT);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_CIPHER", MySQLPDODriver.MYSQL_ATTR_CIPHER);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_KEY", MySQLPDODriver.MYSQL_ATTR_KEY);
        }
Exemple #2
0
        public virtual object __construct(ScriptContext context, object argdsn, [Optional] object argusername, [Optional] object argpassword, [Optional] object argdriver_options)
        {
            string dsn            = PHP.Core.Convert.ObjectToString(argdsn);
            string username       = (argusername == Arg.Default) ? null : PHP.Core.Convert.ObjectToString(argusername);
            string password       = (argpassword == Arg.Default) ? null : PHP.Core.Convert.ObjectToString(argpassword);
            object driver_options = (argdriver_options == Arg.Default) ? null : argdriver_options;

            if (string.IsNullOrEmpty(dsn))
            {
                throw new ArgumentNullException();
            }

            const string uri = "uri:";

            if (dsn.StartsWith(uri))
            {
                Uri url = new Uri(dsn.Substring(uri.Length));
                throw new NotImplementedException("PDO uri handling");
            }
            string[] items = dsn.Split(new char[] { ':' }, 2);
            if (items.Length == 1)
            {
                //TODO : try to search for aliasing
                throw new NotImplementedException("PDO DSN aliasing");
            }
            if (items.Length == 2)
            {
                string drvName = items[0];
                this.m_driver = PDOLibraryDescriptor.GetProvider(drvName);
                if (this.m_driver == null)
                {
                    PDOException.Throw(context, "Driver not found", null, null, null);
                    return(null);
                }
                this.m_con = this.m_driver.OpenConnection(context, items[1], username, password, driver_options);
            }

            if (this.m_driver == null || this.m_con == null)
            {
                PDOException.Throw(context, "Invalid DSN", null, null, null);
                return(null);
            }

            //Defaults
            this.SetAttributeValueNoCheck(ATTR_AUTOCOMMIT, true);
            this.SetAttributeValueNoCheck(ATTR_DEFAULT_FETCH_MODE, FETCH_BOTH);
            this.SetAttributeValueNoCheck(ATTR_DRIVER_NAME, this.m_driver.Scheme);
            this.SetAttributeValueNoCheck(ATTR_ORACLE_NULLS, NULL_NATURAL);
            this.SetAttributeValueNoCheck(ATTR_STRINGIFY_FETCHES, false);
            this.SetAttributeValueNoCheck(ATTR_TIMEOUT, 30000);

            return(null);
        }
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOSQLiteConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new SQLitePDODriver());

            var tPDO = Core.Reflection.DTypeDesc.Create(typeof(PDO));
            PhpMemberAttributes att = PhpMemberAttributes.Public | PhpMemberAttributes.Static;

            ApplicationContext.Default.AddMethodToType(tPDO, att, "sqliteCreateFunction", SQLitePDODriver.PDO_sqliteCreateFunction);
        }
Exemple #4
0
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOSQLiteConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new SQLitePDODriver());

            string fullname = typeof(PDO).Name;
            DType  tPDO     = ApplicationContext.Default.GetType(new QualifiedName(new Name(typeof(PDO).FullName)), ref fullname);

            Core.Reflection.PhpMemberAttributes att = Core.Reflection.PhpMemberAttributes.Public | Core.Reflection.PhpMemberAttributes.Static;
            ApplicationContext.Default.AddMethodToType(tPDO.TypeDesc, att, "sqliteCreateFunction", SQLitePDODriver.PDO_sqliteCreateFunction);
        }
Exemple #5
0
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOMySQLConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new MySQLPDODriver());

            //var pdoDType = DTypeDesc.Create(typeof(PDO));
            //Core.Reflection.PhpMemberAttributes att = Core.Reflection.PhpMemberAttributes.Public | Core.Reflection.PhpMemberAttributes.Static;
            ////ApplicationContext.Default.AddMethodToType(pdoDType, att, "sqliteCreateFunction", MySQLPDODriver.PDO_sqliteCreateFunction);
            ////ApplicationContext.Default.AddConstantToType(pdoDType, PhpMemberAttributes.Public | PhpMemberAttributes.Static, "MYSQL_ATTR_INIT_COMMAND", 1002);
            //ApplicationContext.Default.AddConstantToType(pdoDType, PhpMemberAttributes.Public | PhpMemberAttributes.Static, "MYSQL_ATTR_USE_BUFFERED_QUERY", 1000);
        }
 /// <summary>
 /// Called by the Core after the library is loaded.
 /// </summary>
 protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
 {
     base.Loaded(assemblyAttribute, configStore);
     singleton = this;
     PDOConfiguration.RegisterLegacyOptions();
 }
 /// <summary>
 /// Called by the Core after the library is loaded.
 /// </summary>
 protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
 {
     base.Loaded(assemblyAttribute, configStore);
     singleton = this;
     PDOConfiguration.RegisterLegacyOptions();
 }
Exemple #8
0
 public static string[] Drivers()
 {
     return(PDOLibraryDescriptor.GetDrivers());
 }