php client - mongo db user group pune
DESCRIPTION
A talk on PHP drivers and the official PHP-PECL library. Contains a walk through the library and how to use it.TRANSCRIPT
![Page 1: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/1.jpg)
:{PHP client}
@n1shant
![Page 2: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/2.jpg)
{title : me}
● A Weboniser and a PHP nerd● MongoDb user● DevOps● Love working on Php, and a CakeBaker
![Page 3: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/3.jpg)
{title : Content}
● PECL : MongoDb client● Playing with MongoDb-PHP Client● Using MongoDB-PHP Client
![Page 4: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/4.jpg)
{title : mongoDb-PHP Client}
● Official Library● Easy and effective to use● Sweet-Simple-Easy
![Page 5: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/5.jpg)
{title : core classes}
The Mongo ClientThe MongoDB Class
The Mongo Collection ClassThe Mongo Cursor Class
![Page 6: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/6.jpg)
{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" ); ?>
![Page 7: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/7.jpg)
{title : select database}<?php
$connection = new MongoClient();$db = $connection->dbname;
?>
: Be careful for the Database you provide..!
![Page 8: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/8.jpg)
{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;
?>
![Page 9: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/9.jpg)
{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 );
?>
![Page 10: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/10.jpg)
{title : finding document}<?php
$connection = new MongoClient();$collection = $connection->meetup->MUGPune;
$document = $collection->findOne();var_dump( $document );
?>
![Page 11: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/11.jpg)
{title : using cursor}<?php
$connection = new MongoClient();$collection = $connection->database->collectionName;
$cursor = $collection->find();foreach ( $cursor as $id => $value ) { echo "$id: "; var_dump( $value );}
?>
![Page 12: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/12.jpg)
{title : demo app}
Created a simple task list manager
- http://checklistappmongo-nishant.rhcloud.com/login.php
![Page 13: PHP client - Mongo db User Group Pune](https://reader034.vdocument.in/reader034/viewer/2022051108/54620808b4af9f531c8b4591/html5/thumbnails/13.jpg)
Thanks
Would Love to help & answer your queries...
Nishant Shrivastava@n1shant
nishant-shrivastava