@@ -133,8 +133,8 @@ $m = new MongoDB\Driver\Manager(STANDALONE);
133133
134134try {
135135 /* Drop the collection between runs */
136- $ dropcoll = new MongoDB \Driver \Command (array ("drop " => " people " ));
137- $ m ->executeCommand (" examples " , $ dropcoll );
136+ $ dropcoll = new MongoDB \Driver \Command (array ("drop " => COLLECTION_NAME ));
137+ $ m ->executeCommand (DATABASE_NAME , $ dropcoll );
138138} catch (Exception $ e ) {}
139139
140140$ bulk = new MongoDB \Driver \BulkWrite ;
@@ -179,7 +179,7 @@ $bulk->insert($lockman);
179179
180180
181181/* Insert our fixtures in one bulk write operation */
182- $ m ->executeBulkWrite (" examples.people " , $ bulk );
182+ $ m ->executeBulkWrite (NS , $ bulk );
183183
184184
185185
@@ -188,7 +188,7 @@ $m->executeBulkWrite("examples.people", $bulk);
188188 * converting them back into Person objects -- and the nested Address object!
189189 */
190190$ query = new MongoDB \Driver \Query (array ());
191- foreach ($ m ->executeQuery (" examples.people " , $ query ) as $ person ) {
191+ foreach ($ m ->executeQuery (NS , $ query ) as $ person ) {
192192 echo $ person ->getName (), " has the following address(es): \n" ;
193193 foreach ($ person ->getAddresses () as $ address ) {
194194 echo "\t" , $ address ->getStreetAddress (), "\n" ;
@@ -201,17 +201,19 @@ echo "-----\n";
201201/* Hartmann graduated with a doctorate and deserves a Dr. prefix */
202202$ hartmannFilter = array ("username " => "hartmann " );
203203$ queryHartmann = new MongoDB \Driver \Query ($ hartmannFilter );
204- $ hartmann = $ m ->executeQuery ("examples.people " , $ queryHartmann )->toArray ()[0 ];
204+ $ array = $ m ->executeQuery (NS , $ queryHartmann )->toArray ();
205+ $ hartmann = $ array [0 ];
205206$ hartmann ->setName ("Dr. " . $ hartmann ->getName ());
206207
207- $ retval = $ m ->executeUpdate (" examples.people " , $ hartmannFilter , $ hartmann );
208+ $ retval = $ m ->executeUpdate (NS , $ hartmannFilter , $ hartmann );
208209printf ("Updated %d person (%s) \n" , $ retval ->getModifiedCount (), $ hartmann ->getName ());
209210
210211$ queryAll = new MongoDB \Driver \Query (array ());
211- $ all = $ m ->executeQuery (" examples.people " , $ queryAll )->toArray ();
212+ $ all = $ m ->executeQuery (NS , $ queryAll )->toArray ();
212213foreach ($ all as $ person ) {
213214 if ($ person ->getName () == "Dr. Hartmann Dedrick " ) {
214- var_dump ($ person ->toArray ()["username " ]);
215+ $ array = $ person ->toArray ();
216+ var_dump ($ array ["username " ]);
215217 var_dump ($ person ->getCreatedDateTime ()->format (DATE_RSS ));
216218 var_dump ($ person ->getLastModifiedDateTime ()->format (DATE_RSS ));
217219 }
0 commit comments