本文整理汇总了PHP中FabrikWorker::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::connection方法的具体用法?PHP FabrikWorker::connection怎么用?PHP FabrikWorker::connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::connection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConnection
/**
* @since 3.0b
* helper function get get a connection
* @param mixed - a list table or connection id
*/
public function getConnection($item = null)
{
$jform = JRequest::getVar('jform', array(), 'post');
if (is_object($item)) {
$item = is_null($item->connection_id) ? JArrayHelper::getValue($jform, 'connection_id', -1) : $item->connection_id;
}
$connId = (int) $item;
$config = JFactory::getConfig();
if (!self::$connection) {
self::$connection = array();
}
if (!array_key_exists($connId, self::$connection)) {
$connectionModel = JModel::getInstance('connection', 'FabrikFEModel');
$connectionModel->setId($connId);
if ($connId === -1) {
//-1 for creating new table
$connectionModel->loadDefaultConnection();
$connectionModel->setId($connectionModel->getConnection()->id);
}
$connection = $connectionModel->getConnection();
self::$connection[$connId] = $connectionModel;
if (JError::isError(self::$connection[$connId])) {
JError::handleEcho(self::$connection[$connId]);
}
}
return self::$connection[$connId];
}
示例2: getConnection
/**
* Helper function get get a connection
*
* @param mixed $item A list table or connection id
*
* @since 3.0b
*
* @return object connection
*/
public static function getConnection($item = null)
{
$app = JFactory::getApplication();
$input = $app->input;
$jform = $input->get('jform', array(), 'array');
if (is_object($item)) {
$item = is_null($item->connection_id) ? FArrayHelper::getValue($jform, 'connection_id', -1) : $item->connection_id;
}
$connId = (int) $item;
if (!self::$connection) {
self::$connection = array();
}
if (!array_key_exists($connId, self::$connection)) {
$connectionModel = JModelLegacy::getInstance('connection', 'FabrikFEModel');
$connectionModel->setId($connId);
if ($connId === -1) {
// -1 for creating new table
$connectionModel->loadDefaultConnection();
$connectionModel->setId($connectionModel->getConnection()->id);
}
$connection = $connectionModel->getConnection();
self::$connection[$connId] = $connectionModel;
}
return self::$connection[$connId];
}