diff --git a/docs/api/MongoDB/CRUD.php b/docs/api/MongoDB/CRUD.php deleted file mode 100644 index af9453ae..00000000 --- a/docs/api/MongoDB/CRUD.php +++ /dev/null @@ -1,61 +0,0 @@ -documents[] = $document; - } -} - -class UpdateBatch implements WriteBatch { - function add($document) { - $this->documents[] = $document; - } -} - -class DeleteBatch implements WriteBatch { - function add($document) { - $this->documents[] = $document; - } -} - -class Query { - function __construct($query) {} -} -class Command { - function __construct($command) {} -} - - - - -class WriteResults { - - /* Returns nModified, n, nUserted, .. */ - function getNumbers() { - } - - /* Returns how many operations were executed */ - function getOpCount() { - } - - /* Returns the server that the operation was executed on */ - function getServer() { - } - - /* Any stats available from the server */ - function getTimer() { - } -} - -class QueryResults { - function __construct(Server $server, $cursor_id, $firstBatch) { - } -} - - diff --git a/docs/api/MongoDB/Command/Command.php b/docs/api/MongoDB/Command/Command.php new file mode 100644 index 00000000..ccdd45c4 --- /dev/null +++ b/docs/api/MongoDB/Command/Command.php @@ -0,0 +1,14 @@ +server = $server; + $this->cursorId = (integer) $cursorId; + $this->firstBatch = $firstBatch; + } + + // Iterator methods... + + /** + * @see \MongoDB\Cursor::getId() + */ + public function getId() + { + return $this->cursorId; + } + + /** + * @see \MongoDB\ServerResult::getServer() + */ + public function getServer() + { + return $this->server; + } + + /** + * @see \MongoDB\Cursor::setBatchSize() + */ + public function setBatchSize($batchSize) + { + $this->batchSize = (integer) $batchSize; + } + + // Note: this expects consistent command response documents from the server + static public function createFromCommandResult(CommandResult $result) + { + // extract $cursorId and $firstBatch from $result->getResponse() + + return new static($result->getServer(), $cursorId, $firstBatch); + } +} diff --git a/docs/api/MongoDB/Command/CommandResult.php b/docs/api/MongoDB/Command/CommandResult.php new file mode 100644 index 00000000..8ba37bf7 --- /dev/null +++ b/docs/api/MongoDB/Command/CommandResult.php @@ -0,0 +1,11 @@ +getConnectedServers() as $server) { - if ($server->matchesReadPreference($rp)) { - return $server->executeQuery($namespace, $query); - } - } - throw new NoServerMatchingReadPreference($rp); - } - - final function executeWrite($namespace, \MongoDB\WriteBatch $batch, WriteOptions $wo) { - foreach($this->getConnectedServers() as $server) { - if ($server->isPrimary()) { - return $server->executeWrite($namespace, $batch, $wo); - } - } - - throw new NoPrimaryAvailable; - } -} - diff --git a/docs/api/MongoDB/Manager.php b/docs/api/MongoDB/Manager.php new file mode 100644 index 00000000..2b7d5573 --- /dev/null +++ b/docs/api/MongoDB/Manager.php @@ -0,0 +1,50 @@ +getConnectedServers() as $server) { + if ($server->matchesReadPreference($rp)) { + return $server->executeQuery($namespace, $query); + } + } + throw new NoServerMatchingReadPreference($rp); + } + + final public function executeQuery($namespace, \MongoDB\Query $query, \MongoDB\ReadPreference $rp) + { + foreach($this->getConnectedServers() as $server) { + if ($server->matchesReadPreference($rp)) { + return $server->executeQuery($namespace, $query); + } + } + throw new NoServerMatchingReadPreference($rp); + } + + final function executeWrite($namespace, \MongoDB\WriteBatch $batch, \MongoDB\WriteOptions $wo) + { + foreach($this->getConnectedServers() as $server) { + if ($server->isPrimary()) { + return $server->executeWrite($namespace, $batch, $wo); + } + } + + throw new NoPrimaryAvailable; + } +} diff --git a/docs/api/MongoDB/Query/Query.php b/docs/api/MongoDB/Query/Query.php new file mode 100644 index 00000000..cd73b3e7 --- /dev/null +++ b/docs/api/MongoDB/Query/Query.php @@ -0,0 +1,18 @@ +server = $server; + $this->cursorId = (integer) $cursorId; + } + + // Iterator methods... + + /** + * @see \MongoDB\Cursor::getId() + */ + public function getId() + { + return $this->cursorId; + } + + /** + * @see \MongoDB\ServerResult::getServer() + */ + public function getServer() + { + return $this->server; + } + + /** + * @see \MongoDB\Cursor::setBatchSize() + */ + public function setBatchSize($batchSize) + { + $this->batchSize = (integer) $batchSize; + } +} diff --git a/docs/api/MongoDB/Query/QueryResult.php b/docs/api/MongoDB/Query/QueryResult.php new file mode 100644 index 00000000..79621f0d --- /dev/null +++ b/docs/api/MongoDB/Query/QueryResult.php @@ -0,0 +1,7 @@ +documents[] = $document; + } + + /** + * @see Countable::count() + */ + public function count() + { + return count($this->documents); + } + + /** + * @see WriteBatch::getDocuments() + */ + public function getDocuments() + { + return $this->documents; + } +} diff --git a/docs/api/MongoDB/Write/DeleteResult.php b/docs/api/MongoDB/Write/DeleteResult.php new file mode 100644 index 00000000..9bf41e59 --- /dev/null +++ b/docs/api/MongoDB/Write/DeleteResult.php @@ -0,0 +1,11 @@ +documents[] = $document; + } + + /** + * @see Countable::count() + */ + public function count() + { + return count($this->documents); + } + + /** + * @see WriteBatch::getDocuments() + */ + public function getDocuments() + { + return $this->documents; + } +} diff --git a/docs/api/MongoDB/Write/InsertResult.php b/docs/api/MongoDB/Write/InsertResult.php new file mode 100644 index 00000000..fe8e3082 --- /dev/null +++ b/docs/api/MongoDB/Write/InsertResult.php @@ -0,0 +1,11 @@ +documents[] = $document; + } + + /** + * @see Countable::count() + */ + public function count() + { + return count($this->documents); + } + + /** + * @see WriteBatch::getDocuments() + */ + public function getDocuments() + { + return $this->documents; + } +} diff --git a/docs/api/MongoDB/Write/UpdateResult.php b/docs/api/MongoDB/Write/UpdateResult.php new file mode 100644 index 00000000..38e7f1a9 --- /dev/null +++ b/docs/api/MongoDB/Write/UpdateResult.php @@ -0,0 +1,26 @@ +