本文整理匯總了PHP中EMongoDocument::getDbConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP EMongoDocument::getDbConnection方法的具體用法?PHP EMongoDocument::getDbConnection怎麽用?PHP EMongoDocument::getDbConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EMongoDocument
的用法示例。
在下文中一共展示了EMongoDocument::getDbConnection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: current
/**
* Gets the active record for the current row
* @return EMongoDocument|mixed
* @throws EMongoException
*/
public function current()
{
if (!$this->run) {
if ($this->model->getDbConnection()->queryCachingCount > 0 && $this->model->getDbConnection()->queryCachingDuration > 0 && $this->model->getDbConnection()->queryCacheID !== false && ($cache = Yii::app()->getComponent($this->model->getDbConnection()->queryCacheID)) !== null) {
$this->model->getDbConnection()->queryCachingCount--;
$info = $this->cursor()->info();
$cacheKey = 'yii:dbquery' . $this->model->getDbConnection()->server . ':' . $this->model->getDbConnection()->db . ':' . $this->model->getDbConnection()->getSerialisedQuery(is_array($info['query']) && isset($info['query']['$query']) ? $info['query']['$query'] : array(), $info['fields'], is_array($info['query']) && isset($info['query']['$orderby']) ? $info['query']['$orderby'] : array(), $info['skip'], $info['limit']) . ':' . $this->model->getCollection();
if (($result = $cache->get($cacheKey)) !== false) {
Yii::trace('Query result found in cache', 'extensions.MongoYii.EMongoDocument');
$this->cachedArray = $result;
$this->fromCache = true;
} else {
$this->cachedArray = iterator_to_array($this->cursor);
}
}
if (isset($cache, $cacheKey)) {
$cache->set($cacheKey, $this->cachedArray, $this->model->getDbConnection()->queryCachingDuration, $this->model->getDbConnection()->queryCachingDependency);
$this->fromCache = true;
}
$this->run = true;
}
if ($this->model === null) {
throw new EMongoException(Yii::t('yii', 'The MongoCursor must have a model'));
}
if ($this->fromCache) {
return $this->current = $this->model->populateRecord(current($this->cachedArray), true, $this->partial);
}
return $this->current = $this->model->populateRecord($this->cursor()->current(), true, $this->partial);
}