예제 #1
0
        /// <summary>
        /// Writes MySql legacy options and their values to XML text stream.
        /// Skips options whose values are the same as default values of Phalanger.
        /// </summary>
        /// <param name="writer">XML writer.</param>
        /// <param name="options">A hashtable containing PHP names and option values. Consumed options are removed from the table.</param>
        /// <param name="writePhpNames">Whether to add "phpName" attribute to option nodes.</param>
        public static void LegacyOptionsToXml(XmlTextWriter writer, Hashtable options, bool writePhpNames)         // GENERICS:<string,string>
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            MsSqlLocalConfig  local  = new MsSqlLocalConfig();
            MsSqlGlobalConfig global = new MsSqlGlobalConfig();
            PhpIniXmlWriter   ow     = new PhpIniXmlWriter(writer, options, writePhpNames);

            ow.StartSection("mssql");

            // local:
            ow.WriteOption("mssql.connect_timeout", "ConnectTimeout", 5, local.ConnectTimeout);
            ow.WriteOption("mssql.timeout", "Timeout", 60, local.Timeout);
            ow.WriteOption("mssql.batchsize", "BatchSize", 0, local.BatchSize);

            // global:
            ow.WriteOption("mssql.max_links", "MaxConnections", -1, global.MaxConnections);
            ow.WriteOption("mssql.secure_connection", "NTAuthentication", false, global.NTAuthentication);

            ow.WriteEnd();
        }
예제 #2
0
        /// <summary>
        /// Gets, sets, or restores a value of a legacy configuration option.
        /// </summary>
        private static object GetSetRestore(LocalConfiguration config, string option, object value, IniAction action)
        {
            MsSqlLocalConfig  local    = (MsSqlLocalConfig)config.GetLibraryConfig(MsSqlLibraryDescriptor.Singleton);
            MsSqlLocalConfig  @default = DefaultLocal;
            MsSqlGlobalConfig global   = Global;

            switch (option)
            {
            // local:

            case "mssql.connect_timeout":
                return(PhpIni.GSR(ref local.ConnectTimeout, @default.ConnectTimeout, value, action));

            case "mssql.timeout":
                return(PhpIni.GSR(ref local.Timeout, @default.Timeout, value, action));

            case "mssql.batchsize":
                return(PhpIni.GSR(ref local.BatchSize, @default.BatchSize, value, action));

            // global:

            case "mssql.max_links":
                Debug.Assert(action == IniAction.Get);
                return(PhpIni.GSR(ref global.MaxConnections, 0, null, action));

            case "mssql.secure_connection":
                Debug.Assert(action == IniAction.Get);
                return(PhpIni.GSR(ref global.NTAuthentication, false, null, action));
            }

            Debug.Fail("Option '" + option + "' is supported but not implemented.");
            return(null);
        }
예제 #3
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);
        }
예제 #4
0
		/// <summary>
		/// Writes MySql legacy options and their values to XML text stream.
		/// Skips options whose values are the same as default values of Phalanger.
		/// </summary>
		/// <param name="writer">XML writer.</param>
		/// <param name="options">A hashtable containing PHP names and option values. Consumed options are removed from the table.</param>
		/// <param name="writePhpNames">Whether to add "phpName" attribute to option nodes.</param>
		public static void LegacyOptionsToXml(XmlTextWriter writer, Hashtable options, bool writePhpNames) // GENERICS:<string,string>
		{
			if (writer == null)
				throw new ArgumentNullException("writer");
			if (options == null)
				throw new ArgumentNullException("options");

			MsSqlLocalConfig local = new MsSqlLocalConfig();
			MsSqlGlobalConfig global = new MsSqlGlobalConfig();
			PhpIniXmlWriter ow = new PhpIniXmlWriter(writer, options, writePhpNames);

			ow.StartSection("mssql");

			// local:
			ow.WriteOption("mssql.connect_timeout", "ConnectTimeout", 5, local.ConnectTimeout);
			ow.WriteOption("mssql.timeout", "Timeout", 60, local.Timeout);
			ow.WriteOption("mssql.batchsize", "BatchSize", 0, local.BatchSize);

			// global:
			ow.WriteOption("mssql.max_links", "MaxConnections", -1, global.MaxConnections);
			ow.WriteOption("mssql.secure_connection", "NTAuthentication", false, global.NTAuthentication);

			ow.WriteEnd();
		}