Commit db99d16a authored by Hannes Magnusson's avatar Hannes Magnusson

Fix option parsing and pass correct options to distinct

parent de032a57
...@@ -223,8 +223,7 @@ class Collection { ...@@ -223,8 +223,7 @@ class Collection {
$cmd = array( $cmd = array(
"count" => $this->collname, "count" => $this->collname,
"query" => $filter, "query" => $filter,
$options ) + $options;
);
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument(); $doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
if ($doc["ok"]) { if ($doc["ok"]) {
...@@ -265,13 +264,12 @@ class Collection { ...@@ -265,13 +264,12 @@ class Collection {
} /* }}} */ } /* }}} */
function distinct($fieldName, array $filter = array(), array $options = array()) { /* {{{ */ function distinct($fieldName, array $filter = array(), array $options = array()) { /* {{{ */
$options = array_merge($this->getFindOptions(), $options); $options = array_merge($this->getDistinctOptions(), $options);
$cmd = array( $cmd = array(
"distinct" => $this->collname, "distinct" => $this->collname,
"key" => $fieldName, "key" => $fieldName,
"query" => $filter, "query" => $filter,
$options ) + $options;
);
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument(); $doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
if ($doc["ok"]) { if ($doc["ok"]) {
...@@ -298,6 +296,7 @@ class Collection { ...@@ -298,6 +296,7 @@ class Collection {
return new Exception("FIXME: Unknown error"); return new Exception("FIXME: Unknown error");
} /* }}} */ } /* }}} */
protected function _runCommand($dbname, array $cmd, ReadPreference $rp = null) { /* {{{ */ protected function _runCommand($dbname, array $cmd, ReadPreference $rp = null) { /* {{{ */
//var_dump(\BSON\toJSON(\BSON\fromArray($cmd)));
$command = new Command($cmd); $command = new Command($cmd);
return $this->manager->executeCommand($dbname, $command, $rp); return $this->manager->executeCommand($dbname, $command, $rp);
} /* }}} */ } /* }}} */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment