本文整理匯總了PHP中EMongoDocument::findAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP EMongoDocument::findAll方法的具體用法?PHP EMongoDocument::findAll怎麽用?PHP EMongoDocument::findAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EMongoDocument
的用法示例。
在下文中一共展示了EMongoDocument::findAll方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mongoGet
/**
* Support mongo models interface.
*
* @param \EMongoDocument $model
* @param string|array $where
* @throws ApiException, NotFoundApiException
*/
private function mongoGet($model, $where = null)
{
$criteria = new \EMongoCriteria();
if ($id = \Yii::app()->request->getParam(self::ID, false)) {
$this->data = $model->findByPk($id);
} else {
if ($ids = \Yii::app()->request->getParam(self::IDS, false)) {
// something
} else {
$params = $this->getPaginationParams();
$criteria->offset($params['offset']);
$criteria->limit($params['limit']);
if ($order = \Yii::app()->request->getParam(self::ORDER, false)) {
$params = explode(' ', $order);
$criteria->sort($params[0], $params[1] == 'desc' ? \EMongoCriteria::SORT_DESC : \EMongoCriteria::SORT_ASC);
}
if ($where) {
if (is_array($where)) {
foreach ($where as $cond) {
$params = explode(' ', $cond);
if ($params[1] == 'in') {
$params[2] = $this->manageInCondition($params[2]);
}
$criteria->addCond($params[0], $params[1], is_numeric($params[2]) ? (int) $params[2] : $params[2]);
}
} else {
$params = explode(' ', $where);
if ($params[1] == 'in') {
$params[2] = $this->manageInCondition($params[2]);
}
$criteria->addCond($params[0], $params[1], is_numeric($params[2]) ? (int) $params[2] : $params[2]);
}
}
$this->data = $model->findAll($criteria);
if ($this->data == null) {
throw new NotFoundApiException();
}
}
}
}