Commit b419611f authored by Derick Rethans's avatar Derick Rethans Committed by Jeremy Mikola

Use type map to force arrays instead of objects.

Perhaps, an alternative could be to use access properties instead of array
elements?
parent 60931d82
...@@ -85,6 +85,7 @@ class Count implements Executable ...@@ -85,6 +85,7 @@ class Count implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, $this->createCommand()); $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
$cursor->setTypeMap(array('document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -106,6 +106,7 @@ class CreateCollection implements Executable ...@@ -106,6 +106,7 @@ class CreateCollection implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, $this->createCommand()); $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
$cursor->setTypeMap(array('document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -62,6 +62,7 @@ class Distinct implements Executable ...@@ -62,6 +62,7 @@ class Distinct implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, $this->createCommand()); $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
$cursor->setTypeMap(array('document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -41,6 +41,7 @@ class DropCollection implements Executable ...@@ -41,6 +41,7 @@ class DropCollection implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, new Command(array('drop' => $this->collectionName))); $cursor = $server->executeCommand($this->databaseName, new Command(array('drop' => $this->collectionName)));
$cursor->setTypeMap(array('document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -39,6 +39,7 @@ class DropDatabase implements Executable ...@@ -39,6 +39,7 @@ class DropDatabase implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, new Command(array('dropDatabase' => 1))); $cursor = $server->executeCommand($this->databaseName, new Command(array('dropDatabase' => 1)));
$cursor->setTypeMap(array('document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
...@@ -118,6 +118,7 @@ class FindAndModify implements Executable ...@@ -118,6 +118,7 @@ class FindAndModify implements Executable
public function execute(Server $server) public function execute(Server $server)
{ {
$cursor = $server->executeCommand($this->databaseName, $this->createCommand()); $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
$cursor->setTypeMap(array('document' => 'array'));
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if (empty($result['ok'])) { if (empty($result['ok'])) {
......
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