/** * Get a database object * * Returns the global {@link JDatabase} object, only creating it * if it doesn't already exist. * * @param bool $loadJoomlaDb Force (if true) the loading of the main J database, * needed in admin to connect to J db whilst still using fab db drivers "{package}" * replacement text * * @param mixed $cnnId If null then loads the fabrik default connection, if an int then loads the * specified connection by its id * * @return JDatabaseDriver object */ public static function getDbo($loadJoomlaDb = false, $cnnId = null) { $sig = (int) $loadJoomlaDb . '.' . $cnnId; if (!self::$database) { self::$database = array(); } if (!array_key_exists($sig, self::$database)) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fabrik/tables'); $conf = JFactory::getConfig(); if (!$loadJoomlaDb) { $cnModel = JModelLegacy::getInstance('Connection', 'FabrikFEModel'); $cn = $cnModel->getConnection($cnnId); $host = $cn->host; $user = $cn->user; $password = $cn->password; $database = $cn->database; } else { $host = $conf->get('host'); $user = $conf->get('user'); $password = $conf->get('password'); $database = $conf->get('db'); } $dbPrefix = $conf->get('dbprefix'); $driver = $conf->get('dbtype'); // Test for swapping db table names $driver .= '_fab'; $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $dbPrefix); $version = new JVersion(); self::$database[$sig] = $version->RELEASE > 2.5 ? JDatabaseDriver::getInstance($options) : JDatabase::getInstance($options); FabrikWorker::bigSelects(self::$database[$sig]); } return self::$database[$sig]; }
/** * Once we have a few table joins, our select statements are * getting big enough to hit default select length max in MySQL. * Added per-list setting to enable_big_selects. * * 03/10/2012 - Should preserve any old list settings, but this is now set in the global config * We set it on the main J db in the system plugin setBigSelects() but should do here as well as we * may not be dealing with the same db. * * 2012-10-19 - $$$ hugh - trouble with preserving old list settings is there is no way to change them, without * directly poking around in the params in the database. Commenting out the per-list checking. * * @deprecated now handled in FabrikHelper::getDbo(), as it needs to apply to all queries, including internal / default connection ones. * @since 3/16/2010 * * @return void */ public function setBigSelects() { $fabrikDb = $this->getDb(); FabrikWorker::bigSelects($fabrikDb); }
/** * From Global configuration setting, set big select for main J database * * @since 3.0.7 * * @return void */ protected function setBigSelects() { $db = JFactory::getDbo(); FabrikWorker::bigSelects($db); }