Example #1
0
        /**
         * Get the read configuration for a read / write connection.
         *
         * @param  array  $config
         * @return array
         */
        protected virtual ApplicationDatabaseConnectionConfig getWriteConfig(ApplicationDatabaseConnectionConfig config)
        {
            ApplicationDatabaseConnectionMergeableConfig writeConfig = this.getReadWriteConfig(config, "write");

            return(this.mergeReadWriteConfig(config, writeConfig));
        }
Example #2
0
        /**
         * Merge a configuration for a read / write connection.
         *
         * @param  array  $config
         * @param  array  $merge
         * @return array
         */
        protected ApplicationDatabaseConnectionConfig mergeReadWriteConfig(ApplicationDatabaseConnectionConfig config, ApplicationDatabaseConnectionMergeableConfig extendConfig)
        {
            ApplicationDatabaseConnectionConfig newConfig = config;

            if (extendConfig.name != null)
            {
                newConfig.name = extendConfig.name;
            }
            if (extendConfig.appname != null)
            {
                newConfig.appname = extendConfig.appname;
            }
            if (extendConfig.driver != null)
            {
                newConfig.driver = extendConfig.driver;
            }
            if (extendConfig.host != null)
            {
                newConfig.host = extendConfig.host;
            }
            if (extendConfig.port != null)
            {
                newConfig.port = extendConfig.port;
            }
            if (extendConfig.prefix != null)
            {
                newConfig.prefix = extendConfig.prefix;
            }
            if (extendConfig.database != null)
            {
                newConfig.database = extendConfig.database;
            }
            if (extendConfig.username != null)
            {
                newConfig.username = extendConfig.username;
            }
            if (extendConfig.password != null)
            {
                newConfig.password = extendConfig.password;
            }
            newConfig.read  = null;
            newConfig.write = null;
            return(newConfig);
        }