本文整理汇总了PHP中FabrikWorker::database方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::database方法的具体用法?PHP FabrikWorker::database怎么用?PHP FabrikWorker::database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::database方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDbo
/**
* Get a database object
*
* Returns the global {@link JDatabase} object, only creating it
* if it doesn't already exist.
*
* @param bool 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, if null then loads the fabrik default connection, if an int then loads the specified connection by its id
*
* @return JDatabase 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 . DS . 'components' . DS . 'com_fabrik' . DS . 'tables');
$conf = JFactory::getConfig();
if (!$loadJoomlaDb) {
$cn = JTable::getInstance('Connection', 'FabrikTable');
if (is_null($cnnId)) {
$cn->load(array('default' => 1));
} else {
$cn->load((int) $cnnId);
}
$host = $cn->host;
$user = $cn->user;
$password = $cn->password;
$database = $cn->database;
} else {
$host = $conf->getValue('config.host');
$user = $conf->getValue('config.user');
$password = $conf->getValue('config.password');
$database = $conf->getValue('config.db');
}
$dbprefix = $conf->getValue('config.dbprefix');
$driver = $conf->getValue('config.dbtype');
//test for sawpping db table names
$driver .= '_fab';
$debug = $conf->getValue('config.debug');
$options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $dbprefix);
self::$database[$sig] = JDatabase::getInstance($options);
}
return self::$database[$sig];
}
示例2: getDbo
/**
* 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];
}
示例3: getDbo
/**
* 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 JDatabase 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';
$debug = $conf->get('debug');
$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);
/*
* $$$ hugh - testing doing bigSelects stuff here
* Reason being, some folk on shared hosting plans with very restrictive MySQL
* setups are hitting the 'big selects' problem on Fabrik internal queries, not
* just on their List specific queries. So we need to apply 'big selects' to our
* default connection as well, essentially enabling it for ALL queries we do.
*/
$fbConfig = JComponentHelper::getParams('com_fabrik');
if ($fbConfig->get('enable_big_selects', 0) == '1') {
$fabrikDb = self::$database[$sig];
/**
* Use of OPTION in SET deprecated from MySQL 5.1. onward
* http://www.fabrikar.com/forums/index.php?threads/enable-big-selects-error.39463/#post-198293
* NOTE - technically, using verison_compare on MySQL version could fail, if it's a "gamma"
* release, which PHP desn't grok!
*/
if (version_compare($fabrikDb->getVersion(), '5.1.0', '>=')) {
$fabrikDb->setQuery("SET SQL_BIG_SELECTS=1, GROUP_CONCAT_MAX_LEN=10240");
} else {
$fabrikDb->setQuery("SET OPTION SQL_BIG_SELECTS=1, GROUP_CONCAT_MAX_LEN=10240");
}
$fabrikDb->execute();
}
}
return self::$database[$sig];
}
示例4: getDbo
/**
* 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 JDatabase 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';
$debug = $conf->get('debug');
$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);
/*
* $$$ hugh - testing doing bigSelects stuff here
* Reason being, some folk on shared hosting plans with very restrictive MySQL
* setups are hitting the 'big selects' problem on Fabrik internal queries, not
* just on their List specific queries. So we need to apply 'big selects' to our
* default connection as well, essentially enabling it for ALL queries we do.
*/
$fbConfig = JComponentHelper::getParams('com_fabrik');
if ($fbConfig->get('enable_big_selects', 0) == '1') {
$fabrikDb = self::$database[$sig];
$fabrikDb->setQuery("SET OPTION SQL_BIG_SELECTS=1");
$fabrikDb->execute();
}
}
return self::$database[$sig];
}