@n1shant

:{PHP client}
{title : me}
● A Weboniser and a PHP nerd
● MongoDb user
● DevOps
● Love working on Php, and a CakeBaker
{title : Content}
● PECL : MongoDb client
● Playing with MongoDb-PHP Client
● Using MongoDB-PHP Client
{title : mongoDb-PHP Client}
● Official Library
● Easy and effective to use
● Sweet-Simple-Easy
{title : core classes}
The Mongo Client
The MongoDB Class
The Mongo Collection Class
The Mongo Cursor Class
{title : connection}
<?php
// connects to localhost:27017

$connection = new MongoClient();
// connect to a remote host (d...
{title : select database}
<?php
$connection = new MongoClient();
$db = $connection->dbname;
?>

: Be careful for the Datab...
{title : Collection}
<?php
$connection = new MongoClient();
$db = $connection->meetup;
// select a collection:
$collection...
{title : Inserting a document}
<?php
$meetUpDocument = array(
"name" => "MongoDb User Meet Up",
"slug" => "MUGPune",
"info...
{title : finding document}
<?php
$connection = new MongoClient();
$collection = $connection->meetup->MUGPune;
$document = ...
{title : using cursor}
<?php
$connection = new MongoClient();
$collection = $connection->database->collectionName;
$cursor...
{title : demo app}
Created a simple task list manager
- http://checklistappmongo-nishant.rhcloud.com/login.php
Thanks
Would Love to help & answer your queries...
Nishant Shrivastava
@n1shant
nishant-shrivastava
Upcoming SlideShare
Loading in...5
×

PHP client - Mongo db User Group Pune

1,373

Published on

A talk on PHP drivers and the official PHP-PECL library. Contains a walk through the library and how to use it.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,373
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

PHP client - Mongo db User Group Pune

  1. 1. @n1shant :{PHP client}
  2. 2. {title : me} ● A Weboniser and a PHP nerd ● MongoDb user ● DevOps ● Love working on Php, and a CakeBaker
  3. 3. {title : Content} ● PECL : MongoDb client ● Playing with MongoDb-PHP Client ● Using MongoDB-PHP Client
  4. 4. {title : mongoDb-PHP Client} ● Official Library ● Easy and effective to use ● Sweet-Simple-Easy
  5. 5. {title : core classes} The Mongo Client The MongoDB Class The Mongo Collection Class The Mongo Cursor Class
  6. 6. {title : connection} <?php // connects to localhost:27017 $connection = new MongoClient(); // connect to a remote host (default port: 27017) $connection = new MongoClient( "mongodb://example.com" ); // connect to a remote host at a given port $connection = new MongoClient( "mongodb://example.com:65432" ); ?>
  7. 7. {title : select database} <?php $connection = new MongoClient(); $db = $connection->dbname; ?> : Be careful for the Database you provide..!
  8. 8. {title : Collection} <?php $connection = new MongoClient(); $db = $connection->meetup; // select a collection: $collection = $db->mongodb; // or, directly selecting a database and collection: $collection = $connection->meetup->mongodb; ?>
  9. 9. {title : Inserting a document} <?php $meetUpDocument = array( "name" => "MongoDb User Meet Up", "slug" => "MUGPune", "info" => (object)array( "at" => “Webonise Lab”), "versions" => array("0.1", "0.2") ); $connection = new MongoClient(); $mugCollection = $connection->meetup->MUGPune; $mugCollection->insert( $meetUpDocument ); ?>
  10. 10. {title : finding document} <?php $connection = new MongoClient(); $collection = $connection->meetup->MUGPune; $document = $collection->findOne(); var_dump( $document ); ?>
  11. 11. {title : using cursor} <?php $connection = new MongoClient(); $collection = $connection->database->collectionName; $cursor = $collection->find(); foreach ( $cursor as $id => $value ) { echo "$id: "; var_dump( $value ); } ?>
  12. 12. {title : demo app} Created a simple task list manager - http://checklistappmongo-nishant.rhcloud.com/login.php
  13. 13. Thanks Would Love to help & answer your queries... Nishant Shrivastava @n1shant nishant-shrivastava
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×