Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data type confusion #321

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,15 @@ public function one($db = null)
* The value returned will be the first column in the first row of the query results.
* Column `_id` will be automatically excluded from select fields, if [[select]] is not empty and
* `_id` is not selected explicitly.
* @param mixed $value a reference variable for save result.
* result is the value of the first column in the first row of the query result.
* @param Connection $db the MongoDB connection used to generate the query.
* If this parameter is not given, the `mongodb` application component will be used.
* @return string|null|false the value of the first column in the first row of the query result.
* `false` is returned if the query result is empty.
* @return null|bool `null` is returned if the `emulateExecution` is not empty.
* `false` is returned if the query result is empty otherwise returned true.
* @since 2.1.2
*/
public function scalar($db = null)
public function scalar(&$value, $db = null)
{
if (!empty($this->emulateExecution)) {
return null;
Expand All @@ -391,7 +393,9 @@ public function scalar($db = null)
return false;
}

return reset($row);
$value = reset($row);

return true;
}

/**
Expand Down