Skip to content

Commit bb7452f

Browse files
committed
PHPLIB-54: Update references to driver classes
As of 0.1.4, driver classes are under the MongoDB\Driver namespace. As of 0.1.5, QueryResult and CommandResult were consolidated into a single Result class.
1 parent 0cf95ce commit bb7452f

File tree

5 files changed

+82
-68
lines changed

5 files changed

+82
-68
lines changed

src/Collection.php

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
2+
23
namespace MongoDB;
34

4-
/* {{{ phongo includes */
5-
use MongoDB\Manager;
6-
use MongoDB\Query;
7-
use MongoDB\Command;
8-
use MongoDB\ReadPreference;
9-
use MongoDB\WriteBatch;
10-
/* }}} */
5+
use MongoDB\Driver\Command;
6+
use MongoDB\Driver\Manager;
7+
use MongoDB\Driver\Query;
8+
use MongoDB\Driver\ReadPreference;
9+
use MongoDB\Driver\Result;
10+
use MongoDB\Driver\WriteBatch;
11+
use MongoDB\Driver\WriteConcern;
1112

1213
class Collection
1314
{
@@ -42,15 +43,15 @@ class Collection
4243

4344

4445
/**
45-
* Constructs new MongoDB\Collection instance
46+
* Constructs new Collection instance
4647
*
4748
* This is the suggested CRUD interface when using phongo.
4849
* It implements the MongoDB CRUD specification which is an interface all MongoDB
4950
* supported drivers follow.
5051
*
51-
* @param MongoDB\Manager $manager The phongo Manager instance
52-
* @param MongoDB\WriteConcern $wc The WriteConcern to apply to writes
53-
* @param MongoDB\ReadPreference $rp The ReadPreferences to apply to reads
52+
* @param Manager $manager The phongo Manager instance
53+
* @param WriteConcern $wc The WriteConcern to apply to writes
54+
* @param ReadPreference $rp The ReadPreferences to apply to reads
5455
*/
5556
public function __construct(Manager $manager, $ns, WriteConcern $wc = null, ReadPreference $rp = null)
5657
{
@@ -66,11 +67,11 @@ public function __construct(Manager $manager, $ns, WriteConcern $wc = null, Read
6667
* Performs a find (query) on the collection
6768
*
6869
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
69-
* @see MongoDB\Collection::getFindOptions() for supported $options
70+
* @see Collection::getFindOptions() for supported $options
7071
*
7172
* @param array $filter The find query to execute
7273
* @param array $options Additional options
73-
* @return MongoDB\QueryResult
74+
* @return Result
7475
*/
7576
public function find(array $filter = array(), array $options = array())
7677
{
@@ -87,7 +88,7 @@ public function find(array $filter = array(), array $options = array())
8788
* Performs a find (query) on the collection, returning at most one result
8889
*
8990
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
90-
* @see MongoDB\Collection::getFindOptions() for supported $options
91+
* @see Collection::getFindOptions() for supported $options
9192
*
9293
* @param array $filter The find query to execute
9394
* @param array $options Additional options
@@ -112,7 +113,7 @@ public function findOne(array $filter = array(), array $options = array())
112113
/**
113114
* Retrieves all find options with their default values.
114115
*
115-
* @return array of MongoDB\Collection::find() options
116+
* @return array of Collection::find() options
116117
*/
117118
public function getFindOptions()
118119
{
@@ -142,9 +143,8 @@ public function getFindOptions()
142143
/**
143144
* Indicates the type of cursor to use. This value includes both
144145
* the tailable and awaitData options.
145-
* The default is MongoDB\self::CURSOR_TYPE_NON_TAILABLE.
146+
* The default is Collection::CURSOR_TYPE_NON_TAILABLE.
146147
*
147-
* @see MongoDB\CursorType
148148
* @see http://docs.mongodb.org/manual/reference/operator/meta/comment/
149149
*/
150150
"cursorType" => self::CURSOR_TYPE_NON_TAILABLE,
@@ -232,11 +232,11 @@ final protected function _opQueryFlags($options)
232232
}
233233

234234
/**
235-
* Helper to build a MongoDB\Query object
235+
* Helper to build a Query object
236236
*
237237
* @param array $filter the query document
238238
* @param array $options query/protocol options
239-
* @return MongoDB\Query
239+
* @return Query
240240
* @internal
241241
*/
242242
final protected function _buildQuery($filter, $options)
@@ -312,26 +312,26 @@ public function getBulkOptions()
312312
* - 'insertOne'
313313
* Supports no $extraArgument
314314
* - 'updateMany'
315-
* Requires $extraArgument1, same as $update for MongoDB\Collection\updateMany()
316-
* Optional $extraArgument2, same as $options for MongoDB\Collection\updateMany()
315+
* Requires $extraArgument1, same as $update for Collection::updateMany()
316+
* Optional $extraArgument2, same as $options for Collection::updateMany()
317317
* - 'updateOne'
318-
* Requires $extraArgument1, same as $update for MongoDB\Collection\updateOne()
319-
* Optional $extraArgument2, same as $options for MongoDB\Collection\updateOne()
318+
* Requires $extraArgument1, same as $update for Collection::updateOne()
319+
* Optional $extraArgument2, same as $options for Collection::updateOne()
320320
* - 'replaceOne'
321-
* Requires $extraArgument1, same as $update for MongoDB\Collection\replaceOne()
322-
* Optional $extraArgument2, same as $options for MongoDB\Collection\replaceOne()
321+
* Requires $extraArgument1, same as $update for Collection::replaceOne()
322+
* Optional $extraArgument2, same as $options for Collection::replaceOne()
323323
* - 'deleteOne'
324324
* Supports no $extraArgument
325325
* - 'deleteMany'
326326
* Supports no $extraArgument
327327
*
328328
* @example Collection-bulkWrite.php Using Collection::bulkWrite()
329329
*
330-
* @see MongoDB\Collection::getBulkOptions() for supported $options
330+
* @see Collection::getBulkOptions() for supported $options
331331
*
332332
* @param array $bulk Array of operations
333333
* @param array $options Additional options
334-
* @return MongoDB\WriteResult
334+
* @return WriteResult
335335
*/
336336
public function bulkWrite(array $bulk, array $options = array())
337337
{
@@ -405,11 +405,11 @@ public function bulkWrite(array $bulk, array $options = array())
405405
* Inserts the provided document
406406
*
407407
* @see http://docs.mongodb.org/manual/reference/command/insert/
408-
* @see MongoDB\Collection::getWriteOptions() for supported $options
408+
* @see Collection::getWriteOptions() for supported $options
409409
*
410410
* @param array $document The document to insert
411411
* @param array $options Additional options
412-
* @return MongoDB\InsertResult
412+
* @return InsertResult
413413
*/
414414
public function insertOne(array $document)
415415
{
@@ -442,7 +442,7 @@ final protected function _delete($filter, $limit = 1)
442442
* @see http://docs.mongodb.org/manual/reference/command/delete/
443443
*
444444
* @param array $filter The $filter criteria to delete
445-
* @return MongoDB\DeleteResult
445+
* @return DeleteResult
446446
*/
447447
public function deleteOne(array $filter)
448448
{
@@ -458,7 +458,7 @@ public function deleteOne(array $filter)
458458
* @see http://docs.mongodb.org/manual/reference/command/delete/
459459
*
460460
* @param array $filter The $filter criteria to delete
461-
* @return MongoDB\DeleteResult
461+
* @return DeleteResult
462462
*/
463463
public function deleteMany(array $filter)
464464
{
@@ -484,12 +484,12 @@ protected function _update($filter, $update, $options)
484484
* Replace one document
485485
*
486486
* @see http://docs.mongodb.org/manual/reference/command/update/
487-
* @see MongoDB\Collection::getWriteOptions() for supported $options
487+
* @see Collection::getWriteOptions() for supported $options
488488
*
489489
* @param array $filter The document to be replaced
490490
* @param array $update The document to replace with
491491
* @param array $options Additional options
492-
* @return MongoDB\UpdateResult
492+
* @return UpdateResult
493493
*/
494494
public function replaceOne(array $filter, array $update, array $options = array())
495495
{
@@ -506,12 +506,12 @@ public function replaceOne(array $filter, array $update, array $options = array(
506506
* NOTE: Will update at most ONE document matching $filter
507507
*
508508
* @see http://docs.mongodb.org/manual/reference/command/update/
509-
* @see MongoDB\Collection::getWriteOptions() for supported $options
509+
* @see Collection::getWriteOptions() for supported $options
510510
*
511511
* @param array $filter The document to be replaced
512512
* @param array $update An array of update operators to apply to the document
513513
* @param array $options Additional options
514-
* @return MongoDB\UpdateResult
514+
* @return UpdateResult
515515
*/
516516
public function updateOne(array $filter, array $update, array $options = array())
517517
{
@@ -528,12 +528,12 @@ public function updateOne(array $filter, array $update, array $options = array()
528528
* NOTE: Will update ALL documents matching $filter
529529
*
530530
* @see http://docs.mongodb.org/manual/reference/command/update/
531-
* @see MongoDB\Collection::getWriteOptions() for supported $options
531+
* @see Collection::getWriteOptions() for supported $options
532532
*
533533
* @param array $filter The document to be replaced
534534
* @param array $update An array of update operators to apply to the document
535535
* @param array $options Additional options
536-
* @return MongoDB\UpdateResult
536+
* @return UpdateResult
537537
*/
538538
public function updateMany(array $filter, $update, array $options = array())
539539
{
@@ -547,7 +547,7 @@ public function updateMany(array $filter, $update, array $options = array())
547547
* If no $filter provided, returns the numbers of documents in the collection
548548
*
549549
* @see http://docs.mongodb.org/manual/reference/command/count/
550-
* @see MongoDB\Collection::getCountOptions() for supported $options
550+
* @see Collection::getCountOptions() for supported $options
551551
*
552552
* @param array $filter The find query to execute
553553
* @param array $options Additional options
@@ -560,7 +560,7 @@ public function count(array $filter = array(), array $options = array())
560560
"query" => $filter,
561561
) + $options;
562562

563-
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
563+
$doc = $this->_runCommand($this->dbname, $cmd)->toArray();
564564
if ($doc["ok"]) {
565565
return $doc["n"];
566566
}
@@ -570,7 +570,7 @@ public function count(array $filter = array(), array $options = array())
570570
/**
571571
* Retrieves all count options with their default values.
572572
*
573-
* @return array of MongoDB\Collection::count() options
573+
* @return array of Collection::count() options
574574
*/
575575
public function getCountOptions()
576576
{
@@ -609,7 +609,7 @@ public function getCountOptions()
609609
* Finds the distinct values for a specified field across the collection
610610
*
611611
* @see http://docs.mongodb.org/manual/reference/command/distinct/
612-
* @see MongoDB\Collection::getDistinctOptions() for supported $options
612+
* @see Collection::getDistinctOptions() for supported $options
613613
*
614614
* @param string $fieldName The fieldname to use
615615
* @param array $filter The find query to execute
@@ -625,7 +625,7 @@ public function distinct($fieldName, array $filter = array(), array $options = a
625625
"query" => $filter,
626626
) + $options;
627627

628-
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
628+
$doc = $this->_runCommand($this->dbname, $cmd)->toArray();
629629
if ($doc["ok"]) {
630630
return $doc["values"];
631631
}
@@ -635,7 +635,7 @@ public function distinct($fieldName, array $filter = array(), array $options = a
635635
/**
636636
* Retrieves all distinct options with their default values.
637637
*
638-
* @return array of MongoDB\Collection::distinct() options
638+
* @return array of Collection::distinct() options
639639
*/
640640
public function getDistinctOptions()
641641
{
@@ -653,15 +653,15 @@ public function getDistinctOptions()
653653
* Runs an aggregation framework pipeline
654654
* NOTE: The return value of this method depends on your MongoDB server version
655655
* and possibly options.
656-
* MongoDB 2.6 (and later) will return a MongoDB\QueryCursor by default
657-
* MongoDB pre 2.6 will return a ArrayIterator
656+
* MongoDB 2.6 (and later) will return a Cursor by default
657+
* MongoDB pre 2.6 will return an ArrayIterator
658658
*
659659
* @see http://docs.mongodb.org/manual/reference/command/aggregate/
660-
* @see MongoDB\Collection::getAggregateOptions() for supported $options
660+
* @see Collection::getAggregateOptions() for supported $options
661661
*
662662
* @param array $pipeline The pipeline to execute
663663
* @param array $options Additional options
664-
* @return Iteratable
664+
* @return Iterator
665665
*/
666666
public function aggregate(array $pipeline, array $options = array())
667667
{
@@ -673,7 +673,7 @@ public function aggregate(array $pipeline, array $options = array())
673673
) + $options;
674674

675675
$result = $this->_runCommand($this->dbname, $cmd);
676-
$doc = $result->getResponseDocument();
676+
$doc = $result->toArray();
677677
if (isset($cmd["cursor"]) && $cmd["cursor"]) {
678678
return $result;
679679
} else {
@@ -688,7 +688,7 @@ public function aggregate(array $pipeline, array $options = array())
688688
/**
689689
* Retrieves all aggregate options with their default values.
690690
*
691-
* @return array of MongoDB\Collection::aggregate() options
691+
* @return array of Collection::aggregate() options
692692
*/
693693
public function getAggregateOptions()
694694
{
@@ -752,7 +752,7 @@ protected function _massageAggregateOptions($options)
752752
* Finds a single document and deletes it, returning the original.
753753
*
754754
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
755-
* @see MongoDB\Collection::getFindOneAndDelete() for supported $options
755+
* @see Collection::getFindOneAndDelete() for supported $options
756756
*
757757
* @param array $filter The $filter criteria to search for
758758
* @param array $options Additional options
@@ -767,7 +767,7 @@ public function findOneAndDelete(array $filter, array $options = array())
767767
"query" => $filter,
768768
) + $options;
769769

770-
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
770+
$doc = $this->_runCommand($this->dbname, $cmd)->toArray();
771771
if ($doc["ok"]) {
772772
return $doc["value"];
773773
}
@@ -778,7 +778,7 @@ public function findOneAndDelete(array $filter, array $options = array())
778778
/**
779779
* Retrieves all findOneDelete options with their default values.
780780
*
781-
* @return array of MongoDB\Collection::findOneAndDelete() options
781+
* @return array of Collection::findOneAndDelete() options
782782
*/
783783
public function getFindOneAndDeleteOptions()
784784
{
@@ -811,10 +811,10 @@ public function getFindOneAndDeleteOptions()
811811
* Finds a single document and replaces it, returning either the original or the replaced document
812812
* By default, returns the original document.
813813
* To return the new document set:
814-
* $options = array("returnDocument" => MongoDB\Collection::FIND_ONE_AND_RETURN_AFTER);
814+
* $options = array("returnDocument" => Collection::FIND_ONE_AND_RETURN_AFTER);
815815
*
816816
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
817-
* @see MongoDB\Collection::getFindOneAndReplace() for supported $options
817+
* @see Collection::getFindOneAndReplace() for supported $options
818818
*
819819
* @param array $filter The $filter criteria to search for
820820
* @param array $replacement The document to replace with
@@ -835,7 +835,7 @@ public function findOneAndReplace(array $filter, array $replacement, array $opti
835835
"query" => $filter,
836836
) + $options;
837837

838-
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
838+
$doc = $this->_runCommand($this->dbname, $cmd)->toArray();
839839
if ($doc["ok"]) {
840840
return $doc["value"];
841841
}
@@ -846,7 +846,7 @@ public function findOneAndReplace(array $filter, array $replacement, array $opti
846846
/**
847847
* Retrieves all findOneAndReplace options with their default values.
848848
*
849-
* @return array of MongoDB\Collection::findOneAndReplace() options
849+
* @return array of Collection::findOneAndReplace() options
850850
*/
851851
public function getFindOneAndReplaceOptions()
852852
{
@@ -895,11 +895,11 @@ public function getFindOneAndReplaceOptions()
895895
* Finds a single document and updates it, returning either the original or the updated document
896896
* By default, returns the original document.
897897
* To return the new document set:
898-
* $options = array("returnDocument" => MongoDB\Collection::FIND_ONE_AND_RETURN_AFTER);
898+
* $options = array("returnDocument" => Collection::FIND_ONE_AND_RETURN_AFTER);
899899
*
900900
*
901901
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
902-
* @see MongoDB\Collection::getFindOneAndUpdate() for supported $options
902+
* @see Collection::getFindOneAndUpdate() for supported $options
903903
*
904904
* @param array $filter The $filter criteria to search for
905905
* @param array $update An array of update operators to apply to the document
@@ -920,7 +920,7 @@ public function findOneAndUpdate(array $filter, array $update, array $options =
920920
"query" => $filter,
921921
) + $options;
922922

923-
$doc = $this->_runCommand($this->dbname, $cmd)->getResponseDocument();
923+
$doc = $this->_runCommand($this->dbname, $cmd)->toArray();
924924
if ($doc["ok"]) {
925925
return $doc["value"];
926926
}
@@ -931,7 +931,7 @@ public function findOneAndUpdate(array $filter, array $update, array $options =
931931
/**
932932
* Retrieves all findOneAndUpdate options with their default values.
933933
*
934-
* @return array of MongoDB\Collection::findOneAndUpdate() options
934+
* @return array of Collection::findOneAndUpdate() options
935935
*/
936936
public function getFindOneAndUpdateOptions()
937937
{

0 commit comments

Comments
 (0)