com presentations: s/Mongo/MongoClient/g: slides/map/find-mongo.xml slides/map/finding-food-data-mongo.xml
slides/map/finding-food-import-mongo-script.xml slides/mongodb/aggregation-example.xml slides/mongodb/commands-aggregation-example.xml
slides/mongodb/commands-distinct.xml slides/mongodb/connecting.xml slides/mongodb/cursors.xml slides/mongodb/id.xml slides/mongodb/idx-create-php.xml
slides/mongodb/indexes-geo.xml slides/mongodb/indexes.xml
| From: | Derick Rethans | Date: | Tue, 20 Nov 2012 19:54:55 +0000 |
| Subject: | com presentations: s/Mongo/MongoClient/g: slides/map/find-mongo.xml slides/map/finding-food-data-mongo.xml slides/map/finding-food-import-mongo-script.xml slides/mongodb/aggregation-example.xml slides/mongodb/commands-aggregation-example.xml slides/mongodb/commands-distinct.xml slides/mongodb/connecting.xml slides/mongodb/cursors.xml slides/mongodb/id.xml slides/mongodb/idx-create-php.xml slides/mongodb/indexes-geo.xml slides/mongodb/indexes.xml |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1862@lists.php.net to get a copy of this message | ||
Commit: 8f2c5a4d35219bd902577089e2869ec9ab2d464b
Author: Derick Rethans <github@derickrethans.nl> Tue, 20 Nov 2012 19:54:55 +0000
Parents: ba83fc6948ebb3405d195c97e78cde963eeee941
Branches: master
Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=8f2c5a4d35219bd902577089e2869ec9ab2d464b
Log:
s/Mongo/MongoClient/g
Changed paths:
M slides/map/find-mongo.xml
M slides/map/finding-food-data-mongo.xml
M slides/map/finding-food-import-mongo-script.xml
M slides/mongodb/aggregation-example.xml
M slides/mongodb/commands-aggregation-example.xml
M slides/mongodb/commands-distinct.xml
M slides/mongodb/connecting.xml
M slides/mongodb/cursors.xml
M slides/mongodb/id.xml
M slides/mongodb/idx-create-php.xml
M slides/mongodb/indexes-geo.xml
M slides/mongodb/indexes.xml
M slides/mongodb/indexes2.xml
M slides/mongodb/indexes3.xml
M slides/mongodb/insert.xml
M slides/mongodb/limit-skip.xml
M slides/mongodb/php-connection-string.xml
M slides/mongodb/query-advanced-example-array1.xml
M slides/mongodb/query-advanced-example-array2.xml
M slides/mongodb/query-advanced-example-gte.xml
M slides/mongodb/query.xml
M slides/mongodb/query2.xml
M slides/mongodb/read-preference.xml
M slides/mongodb/safe.xml
M slides/mongodb/safe2.xml
M slides/mongodb/safe3.xml
M slides/mongodb/sort.xml
M slides/mongodb/update-modifiers.xml
M slides/mongodb/update-modifiers2.xml
M slides/mongodb/update-modifiers3.xml
M slides/mongodb/update-modifiers4.xml
M slides/mongodb/update.xml
M slides/mongodb/update2.xml
M slides/mongodb/update2a.xml
M slides/mongodb/upsert.xml
M slides/mongodb/write-import-script-result.xml
diff --git a/slides/map/find-mongo.xml b/slides/map/find-mongo.xml index 5ad7c53..d891f38 100644 --- a/slides/map/find-mongo.xml +++ b/slides/map/find-mongo.xml @@ -2,7 +2,7 @@ <title>Querying our dataset</title> <example> -$m = new Mongo( 'mongodb://localhost' ); +$m = new MongoClient( 'mongodb://localhost' ); $d = $m->selectDb( 'demo' ); $wantedD = isset($_GET['d']) ? $_GET['d']: 1; diff --git a/slides/map/finding-food-data-mongo.xml b/slides/map/finding-food-data-mongo.xml index 59541c0..cbd347e 100644 --- a/slides/map/finding-food-data-mongo.xml +++ b/slides/map/finding-food-data-mongo.xml @@ -4,7 +4,7 @@ <div effect="fade-out"> <example><![CDATA[<?php header('Content-type: text/plain'); -$m = new Mongo( 'mongodb://localhost:27017' ); +$m = new MongoClient( 'mongodb://localhost:27017' ); $c = $m->demo->poi; $c->ensureIndex( array( 'loc' => '2d' ) ); ]]></example> diff --git a/slides/map/finding-food-import-mongo-script.xml b/slides/map/finding-food-import-mongo-script.xml index 5a08bf2..1a45c71 100644 --- a/slides/map/finding-food-import-mongo-script.xml +++ b/slides/map/finding-food-import-mongo-script.xml @@ -3,7 +3,7 @@ <example><![CDATA[<?php $file = $argv[1]; -$m = new Mongo( 'mongodb://localhost:27017' ); +$m = new MongoClient( 'mongodb://localhost:27017' ); $d = $m->selectCollection( 'demo', 'poi' ); $d->drop(); $d->ensureIndex( array( 'loc' => '2d' ) ); diff --git a/slides/mongodb/aggregation-example.xml b/slides/mongodb/aggregation-example.xml index ff56e26..24ec818 100644 --- a/slides/mongodb/aggregation-example.xml +++ b/slides/mongodb/aggregation-example.xml @@ -32,7 +32,7 @@ <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->cities; $res = $c->aggregate( [ diff --git a/slides/mongodb/commands-aggregation-example.xml b/slides/mongodb/commands-aggregation-example.xml index fc347f9..cfb6164 100644 --- a/slides/mongodb/commands-aggregation-example.xml +++ b/slides/mongodb/commands-aggregation-example.xml @@ -2,7 +2,7 @@ <title>Aggregation Example</title> <example result="1"><![CDATA[<?php -$m = new Mongo; $d = $m->demo; $c = $d->articles; $c->drop(); +$m = new MongoClient; $d = $m->demo; $c = $d->articles; $c->drop(); $c->insert( [ "title" => "Profiling PHP Applications", diff --git a/slides/mongodb/commands-distinct.xml b/slides/mongodb/commands-distinct.xml index fd996b2..01562e0 100644 --- a/slides/mongodb/commands-distinct.xml +++ b/slides/mongodb/commands-distinct.xml @@ -2,7 +2,7 @@ <title>Distinct</title> <example result="1"><![CDATA[<?php -$m = new Mongo; $c = $m->demo->pubs; $c->drop(); +$m = new MongoClient; $c = $m->demo->pubs; $c->drop(); $c->insert( [ 'name' => 'Betsy Smith', 'city' => 'London' ] ); $c->insert( [ 'name' => 'London Tavern', 'city' => 'London' ] ); diff --git a/slides/mongodb/connecting.xml b/slides/mongodb/connecting.xml index 74fd477..4fd45b7 100644 --- a/slides/mongodb/connecting.xml +++ b/slides/mongodb/connecting.xml @@ -5,7 +5,7 @@ <break /> <example><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $database = $m->demo; $collection = $database->testCollection; ?>]]> @@ -14,8 +14,8 @@ $collection = $database->testCollection; <blurb>Different connection strings:</blurb> <list> - <bullet>%new Mongo("mongodb://localhost");%</bullet> - <bullet>%new Mongo("mongodb://localhost:29000");%</bullet> - <bullet>%new Mongo("mongodb://mongo.example.com");%</bullet> + <bullet>%new MongoClient("mongodb://localhost");%</bullet> + <bullet>%new MongoClient("mongodb://localhost:29000");%</bullet> + <bullet>%new MongoClient("mongodb://mongo.example.com");%</bullet> </list> </slide> diff --git a/slides/mongodb/cursors.xml b/slides/mongodb/cursors.xml index 13f567d..aa427b2 100644 --- a/slides/mongodb/cursors.xml +++ b/slides/mongodb/cursors.xml @@ -6,7 +6,7 @@ iterator in the form of a %MongoCursor% object.</blurb> <break/> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->talks; $cursor = $c->find( [ 'talks.title' => [ '$exists' => true ] ] ); diff --git a/slides/mongodb/id.xml b/slides/mongodb/id.xml index 61b5b1a..f28c9fe 100644 --- a/slides/mongodb/id.xml +++ b/slides/mongodb/id.xml @@ -7,7 +7,7 @@ </list> <example result="1" stop="true"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->articles; $c->insert( [ 'name' => 'Derick', '_id' => 'derickr' ] ); diff --git a/slides/mongodb/idx-create-php.xml b/slides/mongodb/idx-create-php.xml index 2e05b28..e7ca249 100644 --- a/slides/mongodb/idx-create-php.xml +++ b/slides/mongodb/idx-create-php.xml @@ -5,7 +5,7 @@ <example><![CDATA[ <?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->cities; // Create an index on the name attribute diff --git a/slides/mongodb/indexes-geo.xml b/slides/mongodb/indexes-geo.xml index b20ad3e..4e5eb9c 100644 --- a/slides/mongodb/indexes-geo.xml +++ b/slides/mongodb/indexes-geo.xml @@ -4,7 +4,7 @@ <blurb>Helps you with finding POIs in a 2D space</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo; $c = $m->demo->pubs; $c->drop(); +$m = new MongoClient; $c = $m->demo->pubs; $c->drop(); $c->ensureIndex( array( 'l' => '2d' ) ); $c->insert([ 'name' => 'Betsy Smith', 'l' => [ -0.193, 51.537 ] ]); diff --git a/slides/mongodb/indexes.xml b/slides/mongodb/indexes.xml index 8cdb531..056017b 100644 --- a/slides/mongodb/indexes.xml +++ b/slides/mongodb/indexes.xml @@ -14,7 +14,7 @@ <div effect="fade-in"> <example result="1"><![CDATA[<?php ini_set('xdebug.var_display_max_depth', 1); -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/indexes2.xml b/slides/mongodb/indexes2.xml index 4a3d548..7376ce4 100644 --- a/slides/mongodb/indexes2.xml +++ b/slides/mongodb/indexes2.xml @@ -2,7 +2,7 @@ <title>Indexes</title> <example result="1"><![CDATA[<?php ini_set('xdebug.var_display_max_depth', 1); -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/indexes3.xml b/slides/mongodb/indexes3.xml index 211522b..4f9ade2 100644 --- a/slides/mongodb/indexes3.xml +++ b/slides/mongodb/indexes3.xml @@ -2,7 +2,7 @@ <title>Indexes</title> <example result="1"><![CDATA[<?php ini_set('xdebug.var_display_max_depth', 1); -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/insert.xml b/slides/mongodb/insert.xml index 818de33..be337ce 100644 --- a/slides/mongodb/insert.xml +++ b/slides/mongodb/insert.xml @@ -37,7 +37,7 @@ $document = array( ) ); -$m = new Mongo(); +$m = new MongoClient(); var_dump( $m->demo->talks->insert( $document ) ); ?>]]></example> </div> @@ -59,7 +59,7 @@ $document = [ ] ]; -$m = new Mongo(); +$m = new MongoClient(); var_dump( $m->demo->talks->insert( $document ) ); ?>]]></example> </div> diff --git a/slides/mongodb/limit-skip.xml b/slides/mongodb/limit-skip.xml index 91dc319..839da2c 100644 --- a/slides/mongodb/limit-skip.xml +++ b/slides/mongodb/limit-skip.xml @@ -2,7 +2,7 @@ <title>Cursor methods</title> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->cities; $cursor = $c->find( array( 'country_code' => 'RU' ) ) diff --git a/slides/mongodb/php-connection-string.xml b/slides/mongodb/php-connection-string.xml index 5e76124..f73e92c 100644 --- a/slides/mongodb/php-connection-string.xml +++ b/slides/mongodb/php-connection-string.xml @@ -4,11 +4,11 @@ <example result="0"><![CDATA[<?php $options = array( 'replicaSet' => 'seta' ); -$m = new Mongo( 'mongodb://localhost:13000/?replicaSet=seta' ); +$m = new MongoClient( 'mongodb://localhost:13000/?replicaSet=seta' ); -$m = new Mongo( 'mongodb://localhost:13000,localhost:13001', $options ); +$m = new MongoClient( 'mongodb://localhost:13000,localhost:13001', $options ); -$m = new Mongo( 'mongodb://user:password@localhost:13000/demo', $options ); +$m = new MongoClient( 'mongodb://user:password@localhost:13000/demo', $options ); ?>]]></example> <list> diff --git a/slides/mongodb/query-advanced-example-array1.xml b/slides/mongodb/query-advanced-example-array1.xml index db36b13..50709a6 100644 --- a/slides/mongodb/query-advanced-example-array1.xml +++ b/slides/mongodb/query-advanced-example-array1.xml @@ -3,7 +3,7 @@ <div effect="fade-out"> <example result="2"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->continent; $c->drop(); $c->insert( array( 'name' => 'South America', @@ -28,7 +28,7 @@ meter.</blurb> <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->continent; $r = $c->find( array( 'cities.population' => array( '$gte' => 11000000 ), diff --git a/slides/mongodb/query-advanced-example-array2.xml b/slides/mongodb/query-advanced-example-array2.xml index 3c2a82d..e5c21b7 100644 --- a/slides/mongodb/query-advanced-example-array2.xml +++ b/slides/mongodb/query-advanced-example-array2.xml @@ -2,7 +2,7 @@ <title>Querying: matching array elements ($elemMatch)</title> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->continent; $r = $c->find( array( 'cities' => array( diff --git a/slides/mongodb/query-advanced-example-gte.xml b/slides/mongodb/query-advanced-example-gte.xml index 1bd193a..0cf4f9f 100644 --- a/slides/mongodb/query-advanced-example-gte.xml +++ b/slides/mongodb/query-advanced-example-gte.xml @@ -3,7 +3,7 @@ <div effect="fade-out"> <example><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->cities; $c->insert( array( "name" => "Buenos Aires", "population" => 13076300 ) ); $c->insert( array( "name" => "Dhaka", "population" => 10356500 ) ); @@ -20,7 +20,7 @@ $c->insert( array( "name" => "Mexico City", "population" => 12294193 ) ); <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->cities; $r = $c->find( diff --git a/slides/mongodb/query.xml b/slides/mongodb/query.xml index 116a5a0..3b6dc89 100644 --- a/slides/mongodb/query.xml +++ b/slides/mongodb/query.xml @@ -2,7 +2,7 @@ <title>Querying (1)</title> <example><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); // First "found" item: $record = $m->demo->talks->findOne(); diff --git a/slides/mongodb/query2.xml b/slides/mongodb/query2.xml index afffa95..a07d0be 100644 --- a/slides/mongodb/query2.xml +++ b/slides/mongodb/query2.xml @@ -2,7 +2,7 @@ <title>Querying (2)</title> <example result="0"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); // Find with 'projection' $record = $m->demo->talks->findOne( diff --git a/slides/mongodb/read-preference.xml b/slides/mongodb/read-preference.xml index d676a11..7d7b86d 100644 --- a/slides/mongodb/read-preference.xml +++ b/slides/mongodb/read-preference.xml @@ -2,7 +2,7 @@ <title>Read preferences</title> <example result="0"><![CDATA[<?php -$m = new Mongo( +$m = new MongoClient( 'mongodb://localhost:13000/?' . 'replicaSet=poiset&readPreference=nearest&readPreferenceTags=dc:asia' ); @@ -11,7 +11,7 @@ $c->find(...); ?>]]></example> <blurb>or:</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo( 'mongodb://localhost:13000/?replicaSet=poiset' ); +$m = new MongoClient( 'mongodb://localhost:13000/?replicaSet=poiset' ); $c = $m->phpunit->test; $c->setReadPreference( Mongo::RP_SECONDARY, array( 'dc' => 'europe' ) ); $c->find(...); diff --git a/slides/mongodb/safe.xml b/slides/mongodb/safe.xml index 823b8fb..57551f8 100644 --- a/slides/mongodb/safe.xml +++ b/slides/mongodb/safe.xml @@ -1,32 +1,31 @@ <slide> <title>Checking for errors</title> -<blurb>So far, we have not checked for whether inserts worked.</blurb> +<blurb>So far, we have always checked whether inserts worked.</blurb> <div effect="fade-out"> -<example><![CDATA[<?php -$m = new Mongo; +<blurb>Write acknowledged inserts:</blurb> +<example result="1" stop="true"><![CDATA[<?php +$m = new MongoClient; $c = $m->demo->talks; -$c->insert( array( '_id' => 'derickr' ) ); -$c->insert( array( '_id' => 'derickr' ) ); +try { + $c->insert( array( '_id' => 'derickr' ) ); + $c->insert( array( '_id' => 'derickr' ) ); +} catch ( Exception $e ) { + echo $e->getMessage(), "\n"; +} ?>]]></example> </div> <div effect="fade-in"> -<blurb>"Safe" inserts:</blurb> +<blurb>Ignore errors:</blurb> <example result="1" stop="true"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient('mongodb://localhost/?w=0'); $c = $m->demo->talks; -try { - $c->insert( - array( '_id' => 'derickr' ), // document - array( 'safe' => true ) // options - ); -} catch ( Exception $e ) { - echo $e->getMessage(), "\n"; -} +$c->insert( array( '_id' => 'derickr' ) ); +$c->insert( array( '_id' => 'derickr' ) ); ?>]]></example> </div> </slide> diff --git a/slides/mongodb/safe2.xml b/slides/mongodb/safe2.xml index b7f8167..275a2dc 100644 --- a/slides/mongodb/safe2.xml +++ b/slides/mongodb/safe2.xml @@ -3,10 +3,10 @@ <blurb>Safeness levels:</blurb> <list> - <bullet>Confirm change recorded in memory: %array( 'safe' => true );%</bullet> + <bullet>Confirm change recorded in memory: %array( 'w' => 1 );%</bullet> <bullet>Confirm inclusion in journal: %array( 'j' => true );%</bullet> <bullet>Confirm committed to disk: %array( 'fsync' => true );%</bullet> - <bullet>Confirm replication: %array( 'safe' => true, 'w' => 2 );%</bullet> + <bullet>Confirm replication: %array( 'w' => 2 );%</bullet> </list> <example result="1"><![CDATA[<?php @@ -21,7 +21,7 @@ $c->insert( <blurb>From 1.3:</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo('mongodb://localhost/?safe=true'); +$m = new MongoClient('mongodb://localhost/'); ?>]]></example> </slide> diff --git a/slides/mongodb/safe3.xml b/slides/mongodb/safe3.xml index fd07bd7..21303ab 100644 --- a/slides/mongodb/safe3.xml +++ b/slides/mongodb/safe3.xml @@ -3,16 +3,15 @@ <blurb>Safeness levels:</blurb> <list> - <bullet>Confirm replication: %array( 'safe' => true, 'w' => 2 );%</bullet> + <bullet>Confirm replication: %w=2%</bullet> </list> <example result="1"><![CDATA[<?php -$m = new Mongo( 'mongodb://localhost:13000/?replSet=seta' ); +$m = new MongoClient( 'mongodb://localhost:13000/?replSet=seta&w=2' ); $c = $m->demo->talks; $c->insert( array( '_id' => 'mongodb' ), // document - array( 'safe' => true, 'w' => 2 ) // options ); ?>]]></example> diff --git a/slides/mongodb/sort.xml b/slides/mongodb/sort.xml index 542e0ad..749ed37 100644 --- a/slides/mongodb/sort.xml +++ b/slides/mongodb/sort.xml @@ -2,7 +2,7 @@ <title>Sorting</title> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->cities; $cursor = $c->find( array( 'country_code' => 'IS' ) ) diff --git a/slides/mongodb/update-modifiers.xml b/slides/mongodb/update-modifiers.xml index 947132b..2473d87 100644 --- a/slides/mongodb/update-modifiers.xml +++ b/slides/mongodb/update-modifiers.xml @@ -2,7 +2,7 @@ <title>Modifying documents</title> <example><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->presentations; $c->remove(); diff --git a/slides/mongodb/update-modifiers2.xml b/slides/mongodb/update-modifiers2.xml index c2f0ded..1af4202 100644 --- a/slides/mongodb/update-modifiers2.xml +++ b/slides/mongodb/update-modifiers2.xml @@ -11,7 +11,7 @@ <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->circus; $c->remove(); $c->insert( [ '_id' => 'circ3', 'name' => 'Humberto', 'performers' => 12 ] ); diff --git a/slides/mongodb/update-modifiers3.xml b/slides/mongodb/update-modifiers3.xml index 42b0c79..83ea373 100644 --- a/slides/mongodb/update-modifiers3.xml +++ b/slides/mongodb/update-modifiers3.xml @@ -9,7 +9,7 @@ </list> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->circus; $c->remove(); $c->insert( array( '_id' => 'circ5', 'name' => 'Funny Led' ) ); diff --git a/slides/mongodb/update-modifiers4.xml b/slides/mongodb/update-modifiers4.xml index 91078ab..d9cbb35 100644 --- a/slides/mongodb/update-modifiers4.xml +++ b/slides/mongodb/update-modifiers4.xml @@ -6,7 +6,7 @@ <bullet>%*$bit*% (bitwise updates of field)</bullet> </list> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->bits; $c->remove(); diff --git a/slides/mongodb/update.xml b/slides/mongodb/update.xml index ac2290d..bec578c 100644 --- a/slides/mongodb/update.xml +++ b/slides/mongodb/update.xml @@ -2,7 +2,7 @@ <title>Updating documents</title> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->remove(); diff --git a/slides/mongodb/update2.xml b/slides/mongodb/update2.xml index ae2c59e..dcacc5f 100644 --- a/slides/mongodb/update2.xml +++ b/slides/mongodb/update2.xml @@ -4,7 +4,7 @@ <blurb>Update only updates the *first* document it finds by default.</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/update2a.xml b/slides/mongodb/update2a.xml index 40e2017..ffc247d 100644 --- a/slides/mongodb/update2a.xml +++ b/slides/mongodb/update2a.xml @@ -6,7 +6,7 @@ <blurb>You can set an option to get all matching documents to be updated</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->products; $c->drop(); diff --git a/slides/mongodb/upsert.xml b/slides/mongodb/upsert.xml index 1d9ccf6..701e1f4 100644 --- a/slides/mongodb/upsert.xml +++ b/slides/mongodb/upsert.xml @@ -4,7 +4,7 @@ <blurb>*upsert*: if the record(s) do not exist, insert one.</blurb> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); function birthDay( $c, $name ) diff --git a/slides/mongodb/write-import-script-result.xml b/slides/mongodb/write-import-script-result.xml index 3e45f76..08da078 100644 --- a/slides/mongodb/write-import-script-result.xml +++ b/slides/mongodb/write-import-script-result.xml @@ -10,7 +10,7 @@ $file = $argv[1]; // 1 ADD: Set variable $m to the connection, and $d to the collection "poi" in // the database "demo" on localhost -$m = new Mongo(); +$m = new MongoClient(); $d = $m->demo->poi; // 2 ADD: Drop the collection
diff --git a/slides/map/find-mongo.xml b/slides/map/find-mongo.xml index 5ad7c53..d891f38 100644 --- a/slides/map/find-mongo.xml +++ b/slides/map/find-mongo.xml @@ -2,7 +2,7 @@ <title>Querying our dataset</title> <example> -$m = new Mongo( 'mongodb://localhost' ); +$m = new MongoClient( 'mongodb://localhost' ); $d = $m->selectDb( 'demo' ); $wantedD = isset($_GET['d']) ? $_GET['d']: 1; diff --git a/slides/map/finding-food-data-mongo.xml b/slides/map/finding-food-data-mongo.xml index 59541c0..cbd347e 100644 --- a/slides/map/finding-food-data-mongo.xml +++ b/slides/map/finding-food-data-mongo.xml @@ -4,7 +4,7 @@ <div effect="fade-out"> <example><![CDATA[<?php header('Content-type: text/plain'); -$m = new Mongo( 'mongodb://localhost:27017' ); +$m = new MongoClient( 'mongodb://localhost:27017' ); $c = $m->demo->poi; $c->ensureIndex( array( 'loc' => '2d' ) ); ]]></example> diff --git a/slides/map/finding-food-import-mongo-script.xml b/slides/map/finding-food-import-mongo-script.xml index 5a08bf2..1a45c71 100644 --- a/slides/map/finding-food-import-mongo-script.xml +++ b/slides/map/finding-food-import-mongo-script.xml @@ -3,7 +3,7 @@ <example><![CDATA[<?php $file = $argv[1]; -$m = new Mongo( 'mongodb://localhost:27017' ); +$m = new MongoClient( 'mongodb://localhost:27017' ); $d = $m->selectCollection( 'demo', 'poi' ); $d->drop(); $d->ensureIndex( array( 'loc' => '2d' ) ); diff --git a/slides/mongodb/aggregation-example.xml b/slides/mongodb/aggregation-example.xml index ff56e26..24ec818 100644 --- a/slides/mongodb/aggregation-example.xml +++ b/slides/mongodb/aggregation-example.xml @@ -32,7 +32,7 @@ <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->cities; $res = $c->aggregate( [ diff --git a/slides/mongodb/commands-aggregation-example.xml b/slides/mongodb/commands-aggregation-example.xml index fc347f9..cfb6164 100644 --- a/slides/mongodb/commands-aggregation-example.xml +++ b/slides/mongodb/commands-aggregation-example.xml @@ -2,7 +2,7 @@ <title>Aggregation Example</title> <example result="1"><![CDATA[<?php -$m = new Mongo; $d = $m->demo; $c = $d->articles; $c->drop(); +$m = new MongoClient; $d = $m->demo; $c = $d->articles; $c->drop(); $c->insert( [ "title" => "Profiling PHP Applications", diff --git a/slides/mongodb/commands-distinct.xml b/slides/mongodb/commands-distinct.xml index fd996b2..01562e0 100644 --- a/slides/mongodb/commands-distinct.xml +++ b/slides/mongodb/commands-distinct.xml @@ -2,7 +2,7 @@ <title>Distinct</title> <example result="1"><![CDATA[<?php -$m = new Mongo; $c = $m->demo->pubs; $c->drop(); +$m = new MongoClient; $c = $m->demo->pubs; $c->drop(); $c->insert( [ 'name' => 'Betsy Smith', 'city' => 'London' ] ); $c->insert( [ 'name' => 'London Tavern', 'city' => 'London' ] ); diff --git a/slides/mongodb/connecting.xml b/slides/mongodb/connecting.xml index 74fd477..4fd45b7 100644 --- a/slides/mongodb/connecting.xml +++ b/slides/mongodb/connecting.xml @@ -5,7 +5,7 @@ <break /> <example><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $database = $m->demo; $collection = $database->testCollection; ?>]]> @@ -14,8 +14,8 @@ $collection = $database->testCollection; <blurb>Different connection strings:</blurb> <list> - <bullet>%new Mongo("mongodb://localhost");%</bullet> - <bullet>%new Mongo("mongodb://localhost:29000");%</bullet> - <bullet>%new Mongo("mongodb://mongo.example.com");%</bullet> + <bullet>%new MongoClient("mongodb://localhost");%</bullet> + <bullet>%new MongoClient("mongodb://localhost:29000");%</bullet> + <bullet>%new MongoClient("mongodb://mongo.example.com");%</bullet> </list> </slide> diff --git a/slides/mongodb/cursors.xml b/slides/mongodb/cursors.xml index 13f567d..aa427b2 100644 --- a/slides/mongodb/cursors.xml +++ b/slides/mongodb/cursors.xml @@ -6,7 +6,7 @@ iterator in the form of a %MongoCursor% object.</blurb> <break/> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->talks; $cursor = $c->find( [ 'talks.title' => [ '$exists' => true ] ] ); diff --git a/slides/mongodb/id.xml b/slides/mongodb/id.xml index 61b5b1a..f28c9fe 100644 --- a/slides/mongodb/id.xml +++ b/slides/mongodb/id.xml @@ -7,7 +7,7 @@ </list> <example result="1" stop="true"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->articles; $c->insert( [ 'name' => 'Derick', '_id' => 'derickr' ] ); diff --git a/slides/mongodb/idx-create-php.xml b/slides/mongodb/idx-create-php.xml index 2e05b28..e7ca249 100644 --- a/slides/mongodb/idx-create-php.xml +++ b/slides/mongodb/idx-create-php.xml @@ -5,7 +5,7 @@ <example><![CDATA[ <?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->cities; // Create an index on the name attribute diff --git a/slides/mongodb/indexes-geo.xml b/slides/mongodb/indexes-geo.xml index b20ad3e..4e5eb9c 100644 --- a/slides/mongodb/indexes-geo.xml +++ b/slides/mongodb/indexes-geo.xml @@ -4,7 +4,7 @@ <blurb>Helps you with finding POIs in a 2D space</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo; $c = $m->demo->pubs; $c->drop(); +$m = new MongoClient; $c = $m->demo->pubs; $c->drop(); $c->ensureIndex( array( 'l' => '2d' ) ); $c->insert([ 'name' => 'Betsy Smith', 'l' => [ -0.193, 51.537 ] ]); diff --git a/slides/mongodb/indexes.xml b/slides/mongodb/indexes.xml index 8cdb531..056017b 100644 --- a/slides/mongodb/indexes.xml +++ b/slides/mongodb/indexes.xml @@ -14,7 +14,7 @@ <div effect="fade-in"> <example result="1"><![CDATA[<?php ini_set('xdebug.var_display_max_depth', 1); -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/indexes2.xml b/slides/mongodb/indexes2.xml index 4a3d548..7376ce4 100644 --- a/slides/mongodb/indexes2.xml +++ b/slides/mongodb/indexes2.xml @@ -2,7 +2,7 @@ <title>Indexes</title> <example result="1"><![CDATA[<?php ini_set('xdebug.var_display_max_depth', 1); -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/indexes3.xml b/slides/mongodb/indexes3.xml index 211522b..4f9ade2 100644 --- a/slides/mongodb/indexes3.xml +++ b/slides/mongodb/indexes3.xml @@ -2,7 +2,7 @@ <title>Indexes</title> <example result="1"><![CDATA[<?php ini_set('xdebug.var_display_max_depth', 1); -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/insert.xml b/slides/mongodb/insert.xml index 818de33..be337ce 100644 --- a/slides/mongodb/insert.xml +++ b/slides/mongodb/insert.xml @@ -37,7 +37,7 @@ $document = array( ) ); -$m = new Mongo(); +$m = new MongoClient(); var_dump( $m->demo->talks->insert( $document ) ); ?>]]></example> </div> @@ -59,7 +59,7 @@ $document = [ ] ]; -$m = new Mongo(); +$m = new MongoClient(); var_dump( $m->demo->talks->insert( $document ) ); ?>]]></example> </div> diff --git a/slides/mongodb/limit-skip.xml b/slides/mongodb/limit-skip.xml index 91dc319..839da2c 100644 --- a/slides/mongodb/limit-skip.xml +++ b/slides/mongodb/limit-skip.xml @@ -2,7 +2,7 @@ <title>Cursor methods</title> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->cities; $cursor = $c->find( array( 'country_code' => 'RU' ) ) diff --git a/slides/mongodb/php-connection-string.xml b/slides/mongodb/php-connection-string.xml index 5e76124..f73e92c 100644 --- a/slides/mongodb/php-connection-string.xml +++ b/slides/mongodb/php-connection-string.xml @@ -4,11 +4,11 @@ <example result="0"><![CDATA[<?php $options = array( 'replicaSet' => 'seta' ); -$m = new Mongo( 'mongodb://localhost:13000/?replicaSet=seta' ); +$m = new MongoClient( 'mongodb://localhost:13000/?replicaSet=seta' ); -$m = new Mongo( 'mongodb://localhost:13000,localhost:13001', $options ); +$m = new MongoClient( 'mongodb://localhost:13000,localhost:13001', $options ); -$m = new Mongo( 'mongodb://user:password@localhost:13000/demo', $options ); +$m = new MongoClient( 'mongodb://user:password@localhost:13000/demo', $options ); ?>]]></example> <list> diff --git a/slides/mongodb/query-advanced-example-array1.xml b/slides/mongodb/query-advanced-example-array1.xml index db36b13..50709a6 100644 --- a/slides/mongodb/query-advanced-example-array1.xml +++ b/slides/mongodb/query-advanced-example-array1.xml @@ -3,7 +3,7 @@ <div effect="fade-out"> <example result="2"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->continent; $c->drop(); $c->insert( array( 'name' => 'South America', @@ -28,7 +28,7 @@ meter.</blurb> <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->continent; $r = $c->find( array( 'cities.population' => array( '$gte' => 11000000 ), diff --git a/slides/mongodb/query-advanced-example-array2.xml b/slides/mongodb/query-advanced-example-array2.xml index 3c2a82d..e5c21b7 100644 --- a/slides/mongodb/query-advanced-example-array2.xml +++ b/slides/mongodb/query-advanced-example-array2.xml @@ -2,7 +2,7 @@ <title>Querying: matching array elements ($elemMatch)</title> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->continent; $r = $c->find( array( 'cities' => array( diff --git a/slides/mongodb/query-advanced-example-gte.xml b/slides/mongodb/query-advanced-example-gte.xml index 1bd193a..0cf4f9f 100644 --- a/slides/mongodb/query-advanced-example-gte.xml +++ b/slides/mongodb/query-advanced-example-gte.xml @@ -3,7 +3,7 @@ <div effect="fade-out"> <example><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->cities; $c->insert( array( "name" => "Buenos Aires", "population" => 13076300 ) ); $c->insert( array( "name" => "Dhaka", "population" => 10356500 ) ); @@ -20,7 +20,7 @@ $c->insert( array( "name" => "Mexico City", "population" => 12294193 ) ); <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->cities; $r = $c->find( diff --git a/slides/mongodb/query.xml b/slides/mongodb/query.xml index 116a5a0..3b6dc89 100644 --- a/slides/mongodb/query.xml +++ b/slides/mongodb/query.xml @@ -2,7 +2,7 @@ <title>Querying (1)</title> <example><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); // First "found" item: $record = $m->demo->talks->findOne(); diff --git a/slides/mongodb/query2.xml b/slides/mongodb/query2.xml index afffa95..a07d0be 100644 --- a/slides/mongodb/query2.xml +++ b/slides/mongodb/query2.xml @@ -2,7 +2,7 @@ <title>Querying (2)</title> <example result="0"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); // Find with 'projection' $record = $m->demo->talks->findOne( diff --git a/slides/mongodb/read-preference.xml b/slides/mongodb/read-preference.xml index d676a11..7d7b86d 100644 --- a/slides/mongodb/read-preference.xml +++ b/slides/mongodb/read-preference.xml @@ -2,7 +2,7 @@ <title>Read preferences</title> <example result="0"><![CDATA[<?php -$m = new Mongo( +$m = new MongoClient( 'mongodb://localhost:13000/?' . 'replicaSet=poiset&readPreference=nearest&readPreferenceTags=dc:asia' ); @@ -11,7 +11,7 @@ $c->find(...); ?>]]></example> <blurb>or:</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo( 'mongodb://localhost:13000/?replicaSet=poiset' ); +$m = new MongoClient( 'mongodb://localhost:13000/?replicaSet=poiset' ); $c = $m->phpunit->test; $c->setReadPreference( Mongo::RP_SECONDARY, array( 'dc' => 'europe' ) ); $c->find(...); diff --git a/slides/mongodb/safe.xml b/slides/mongodb/safe.xml index 823b8fb..57551f8 100644 --- a/slides/mongodb/safe.xml +++ b/slides/mongodb/safe.xml @@ -1,32 +1,31 @@ <slide> <title>Checking for errors</title> -<blurb>So far, we have not checked for whether inserts worked.</blurb> +<blurb>So far, we have always checked whether inserts worked.</blurb> <div effect="fade-out"> -<example><![CDATA[<?php -$m = new Mongo; +<blurb>Write acknowledged inserts:</blurb> +<example result="1" stop="true"><![CDATA[<?php +$m = new MongoClient; $c = $m->demo->talks; -$c->insert( array( '_id' => 'derickr' ) ); -$c->insert( array( '_id' => 'derickr' ) ); +try { + $c->insert( array( '_id' => 'derickr' ) ); + $c->insert( array( '_id' => 'derickr' ) ); +} catch ( Exception $e ) { + echo $e->getMessage(), "\n"; +} ?>]]></example> </div> <div effect="fade-in"> -<blurb>"Safe" inserts:</blurb> +<blurb>Ignore errors:</blurb> <example result="1" stop="true"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient('mongodb://localhost/?w=0'); $c = $m->demo->talks; -try { - $c->insert( - array( '_id' => 'derickr' ), // document - array( 'safe' => true ) // options - ); -} catch ( Exception $e ) { - echo $e->getMessage(), "\n"; -} +$c->insert( array( '_id' => 'derickr' ) ); +$c->insert( array( '_id' => 'derickr' ) ); ?>]]></example> </div> </slide> diff --git a/slides/mongodb/safe2.xml b/slides/mongodb/safe2.xml index b7f8167..275a2dc 100644 --- a/slides/mongodb/safe2.xml +++ b/slides/mongodb/safe2.xml @@ -3,10 +3,10 @@ <blurb>Safeness levels:</blurb> <list> - <bullet>Confirm change recorded in memory: %array( 'safe' => true );%</bullet> + <bullet>Confirm change recorded in memory: %array( 'w' => 1 );%</bullet> <bullet>Confirm inclusion in journal: %array( 'j' => true );%</bullet> <bullet>Confirm committed to disk: %array( 'fsync' => true );%</bullet> - <bullet>Confirm replication: %array( 'safe' => true, 'w' => 2 );%</bullet> + <bullet>Confirm replication: %array( 'w' => 2 );%</bullet> </list> <example result="1"><![CDATA[<?php @@ -21,7 +21,7 @@ $c->insert( <blurb>From 1.3:</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo('mongodb://localhost/?safe=true'); +$m = new MongoClient('mongodb://localhost/'); ?>]]></example> </slide> diff --git a/slides/mongodb/safe3.xml b/slides/mongodb/safe3.xml index fd07bd7..21303ab 100644 --- a/slides/mongodb/safe3.xml +++ b/slides/mongodb/safe3.xml @@ -3,16 +3,15 @@ <blurb>Safeness levels:</blurb> <list> - <bullet>Confirm replication: %array( 'safe' => true, 'w' => 2 );%</bullet> + <bullet>Confirm replication: %w=2%</bullet> </list> <example result="1"><![CDATA[<?php -$m = new Mongo( 'mongodb://localhost:13000/?replSet=seta' ); +$m = new MongoClient( 'mongodb://localhost:13000/?replSet=seta&w=2' ); $c = $m->demo->talks; $c->insert( array( '_id' => 'mongodb' ), // document - array( 'safe' => true, 'w' => 2 ) // options ); ?>]]></example> diff --git a/slides/mongodb/sort.xml b/slides/mongodb/sort.xml index 542e0ad..749ed37 100644 --- a/slides/mongodb/sort.xml +++ b/slides/mongodb/sort.xml @@ -2,7 +2,7 @@ <title>Sorting</title> <example result="1"><![CDATA[<?php -$m = new Mongo(); +$m = new MongoClient(); $c = $m->demo->cities; $cursor = $c->find( array( 'country_code' => 'IS' ) ) diff --git a/slides/mongodb/update-modifiers.xml b/slides/mongodb/update-modifiers.xml index 947132b..2473d87 100644 --- a/slides/mongodb/update-modifiers.xml +++ b/slides/mongodb/update-modifiers.xml @@ -2,7 +2,7 @@ <title>Modifying documents</title> <example><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->presentations; $c->remove(); diff --git a/slides/mongodb/update-modifiers2.xml b/slides/mongodb/update-modifiers2.xml index c2f0ded..1af4202 100644 --- a/slides/mongodb/update-modifiers2.xml +++ b/slides/mongodb/update-modifiers2.xml @@ -11,7 +11,7 @@ <div effect="fade-in"> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->circus; $c->remove(); $c->insert( [ '_id' => 'circ3', 'name' => 'Humberto', 'performers' => 12 ] ); diff --git a/slides/mongodb/update-modifiers3.xml b/slides/mongodb/update-modifiers3.xml index 42b0c79..83ea373 100644 --- a/slides/mongodb/update-modifiers3.xml +++ b/slides/mongodb/update-modifiers3.xml @@ -9,7 +9,7 @@ </list> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->circus; $c->remove(); $c->insert( array( '_id' => 'circ5', 'name' => 'Funny Led' ) ); diff --git a/slides/mongodb/update-modifiers4.xml b/slides/mongodb/update-modifiers4.xml index 91078ab..d9cbb35 100644 --- a/slides/mongodb/update-modifiers4.xml +++ b/slides/mongodb/update-modifiers4.xml @@ -6,7 +6,7 @@ <bullet>%*$bit*% (bitwise updates of field)</bullet> </list> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->bits; $c->remove(); diff --git a/slides/mongodb/update.xml b/slides/mongodb/update.xml index ac2290d..bec578c 100644 --- a/slides/mongodb/update.xml +++ b/slides/mongodb/update.xml @@ -2,7 +2,7 @@ <title>Updating documents</title> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->remove(); diff --git a/slides/mongodb/update2.xml b/slides/mongodb/update2.xml index ae2c59e..dcacc5f 100644 --- a/slides/mongodb/update2.xml +++ b/slides/mongodb/update2.xml @@ -4,7 +4,7 @@ <blurb>Update only updates the *first* document it finds by default.</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); diff --git a/slides/mongodb/update2a.xml b/slides/mongodb/update2a.xml index 40e2017..ffc247d 100644 --- a/slides/mongodb/update2a.xml +++ b/slides/mongodb/update2a.xml @@ -6,7 +6,7 @@ <blurb>You can set an option to get all matching documents to be updated</blurb> <example result="0"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->products; $c->drop(); diff --git a/slides/mongodb/upsert.xml b/slides/mongodb/upsert.xml index 1d9ccf6..701e1f4 100644 --- a/slides/mongodb/upsert.xml +++ b/slides/mongodb/upsert.xml @@ -4,7 +4,7 @@ <blurb>*upsert*: if the record(s) do not exist, insert one.</blurb> <example result="1"><![CDATA[<?php -$m = new Mongo; +$m = new MongoClient; $c = $m->demo->elephpants; $c->drop(); function birthDay( $c, $name ) diff --git a/slides/mongodb/write-import-script-result.xml b/slides/mongodb/write-import-script-result.xml index 3e45f76..08da078 100644 --- a/slides/mongodb/write-import-script-result.xml +++ b/slides/mongodb/write-import-script-result.xml @@ -10,7 +10,7 @@ $file = $argv[1]; // 1 ADD: Set variable $m to the connection, and $d to the collection "poi" in // the database "demo" on localhost -$m = new Mongo(); +$m = new MongoClient(); $d = $m->demo->poi; // 2 ADD: Drop the collection