-
-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Description
Example
yii2-mongodb/src/ActiveQuery.php
Lines 127 to 156 in 8f53e48
/** | |
* Executes query and returns all results as an array. | |
* @param Connection $db the Mongo connection used to execute the query. | |
* If null, the Mongo connection returned by [[modelClass]] will be used. | |
* @return array|ActiveRecord the query results. If the query results in nothing, an empty array will be returned. | |
*/ | |
public function all($db = null) | |
{ | |
return parent::all($db); | |
} | |
/** | |
* Executes query and returns a single row of result. | |
* @param Connection $db the Mongo connection used to execute the query. | |
* If null, the Mongo connection returned by [[modelClass]] will be used. | |
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]], | |
* the query result may be either an array or an ActiveRecord object. Null will be returned | |
* if the query results in nothing. | |
*/ | |
public function one($db = null) | |
{ | |
$row = parent::one($db); | |
if ($row !== false) { | |
$models = $this->populate([$row]); | |
return reset($models) ?: null; | |
} | |
return null; | |
} | |
Yii2
https://github.com/yiisoft/yii2/blob/ec57b0bd2a2da2bbe1bbe00fb115cb91478a9a9d/framework/db/ActiveQuery.php#L72-L80
Metadata
Metadata
Assignees
Labels
No labels