SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
@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 (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" );
?>
{title : select database}
<?php
$connection = new MongoClient();
$db = $connection->dbname;
?>

: Be careful for the Database you provide..!
{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;
?>
{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 );
?>
{title : finding document}
<?php
$connection = new MongoClient();
$collection = $connection->meetup->MUGPune;
$document = $collection->findOne();
var_dump( $document );
?>
{title : using cursor}
<?php
$connection = new MongoClient();
$collection = $connection->database->collectionName;
$cursor = $collection->find();
foreach ( $cursor as $id => $value ) {
echo "$id: ";
var_dump( $value );
}
?>
{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

Más contenido relacionado

La actualidad más candente

Google Chromebook for the Enterprise: Yeah or Meh?
Google Chromebook for the Enterprise: Yeah or Meh?Google Chromebook for the Enterprise: Yeah or Meh?
Google Chromebook for the Enterprise: Yeah or Meh?Ericom Software
 
DomDisc and the Domino data api
DomDisc and the Domino data apiDomDisc and the Domino data api
DomDisc and the Domino data apiJens Bruntt
 
Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven ProgrammingKamal Hussain
 
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...WSO2
 
3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don'tF5 Buddy
 
Creating dynamic json in Mule
Creating dynamic json in MuleCreating dynamic json in Mule
Creating dynamic json in MuleF K
 
Presentation of JSConf.eu
Presentation of JSConf.euPresentation of JSConf.eu
Presentation of JSConf.euFredrik Wendt
 
Subversion Clients for the Mac - svnX
Subversion Clients  for the Mac - svnXSubversion Clients  for the Mac - svnX
Subversion Clients for the Mac - svnXBen MacNeill
 
Understanding the Node.js Platform
Understanding the Node.js PlatformUnderstanding the Node.js Platform
Understanding the Node.js PlatformDomenic Denicola
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformerirfan1008
 
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...Vitalii Kukhar
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JSFestUA
 

La actualidad más candente (20)

Mule: JSON to Object
Mule: JSON to ObjectMule: JSON to Object
Mule: JSON to Object
 
Google Chromebook for the Enterprise: Yeah or Meh?
Google Chromebook for the Enterprise: Yeah or Meh?Google Chromebook for the Enterprise: Yeah or Meh?
Google Chromebook for the Enterprise: Yeah or Meh?
 
DomDisc and the Domino data api
DomDisc and the Domino data apiDomDisc and the Domino data api
DomDisc and the Domino data api
 
Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven Programming
 
Mule parsing with json part2
Mule parsing with json part2Mule parsing with json part2
Mule parsing with json part2
 
OpenCms Days 2013 - Site Management Tool
OpenCms Days 2013 - Site Management ToolOpenCms Days 2013 - Site Management Tool
OpenCms Days 2013 - Site Management Tool
 
Mule parsing with json
Mule parsing with jsonMule parsing with json
Mule parsing with json
 
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
 
3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't
 
Reintroducing Web Technology
Reintroducing Web TechnologyReintroducing Web Technology
Reintroducing Web Technology
 
Creating dynamic json in Mule
Creating dynamic json in MuleCreating dynamic json in Mule
Creating dynamic json in Mule
 
Presentation of JSConf.eu
Presentation of JSConf.euPresentation of JSConf.eu
Presentation of JSConf.eu
 
OpenCms Days 2016: Keynote - Introducing OpenCms 10.5
OpenCms Days 2016:   Keynote - Introducing OpenCms 10.5OpenCms Days 2016:   Keynote - Introducing OpenCms 10.5
OpenCms Days 2016: Keynote - Introducing OpenCms 10.5
 
Subversion Clients for the Mac - svnX
Subversion Clients  for the Mac - svnXSubversion Clients  for the Mac - svnX
Subversion Clients for the Mac - svnX
 
Node js
Node jsNode js
Node js
 
Understanding the Node.js Platform
Understanding the Node.js PlatformUnderstanding the Node.js Platform
Understanding the Node.js Platform
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
JS Fest 2019: Comparing Node.js processes and threads for clustering HTTP, TC...
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
 
Node js
Node jsNode js
Node js
 

Destacado

Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environmentKapil Sharma
 
Design patterns in PHP - PHP TEAM
Design patterns in PHP - PHP TEAMDesign patterns in PHP - PHP TEAM
Design patterns in PHP - PHP TEAMNishant Shrivastava
 
MongoDB training for java software engineers
MongoDB training for java software engineersMongoDB training for java software engineers
MongoDB training for java software engineersMoshe Kaplan
 
Your first 5 PHP design patterns - ThatConference 2012
Your first 5 PHP design patterns - ThatConference 2012Your first 5 PHP design patterns - ThatConference 2012
Your first 5 PHP design patterns - ThatConference 2012Aaron Saray
 
Build an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hourBuild an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hourTrisha Gee
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know Norberto Leite
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMongoDB
 

Destacado (7)

Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environment
 
Design patterns in PHP - PHP TEAM
Design patterns in PHP - PHP TEAMDesign patterns in PHP - PHP TEAM
Design patterns in PHP - PHP TEAM
 
MongoDB training for java software engineers
MongoDB training for java software engineersMongoDB training for java software engineers
MongoDB training for java software engineers
 
Your first 5 PHP design patterns - ThatConference 2012
Your first 5 PHP design patterns - ThatConference 2012Your first 5 PHP design patterns - ThatConference 2012
Your first 5 PHP design patterns - ThatConference 2012
 
Build an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hourBuild an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hour
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDB
 

Similar a PHP client - Mongo db User Group Pune

PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATIONkrutitrivedi
 
Design Web Service API by HungerStation
Design Web Service API by HungerStationDesign Web Service API by HungerStation
Design Web Service API by HungerStationArabNet ME
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsMongoDB
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsMongoDB
 
PHP Variables & Comments 01
PHP Variables & Comments 01PHP Variables & Comments 01
PHP Variables & Comments 01Spy Seat
 
오픈 소스 프로그래밍 - NoSQL with Python
오픈 소스 프로그래밍 - NoSQL with Python오픈 소스 프로그래밍 - NoSQL with Python
오픈 소스 프로그래밍 - NoSQL with PythonIan Choi
 
Webinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBWebinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBMongoDB
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 
Extensible web #html5j
Extensible web #html5jExtensible web #html5j
Extensible web #html5jJxck Jxck
 
Introduction to rails
Introduction to railsIntroduction to rails
Introduction to railsGo Asgard
 
Pymongo password change made easy
Pymongo password change made easyPymongo password change made easy
Pymongo password change made easyDarshan Jayarama
 
Integrating Node.js with PHP
Integrating Node.js with PHPIntegrating Node.js with PHP
Integrating Node.js with PHPLee Boynton
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementAdrian Cardenas
 

Similar a PHP client - Mongo db User Group Pune (20)

PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATION
 
Design Web Service API by HungerStation
Design Web Service API by HungerStationDesign Web Service API by HungerStation
Design Web Service API by HungerStation
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
PHP Variables & Comments 01
PHP Variables & Comments 01PHP Variables & Comments 01
PHP Variables & Comments 01
 
오픈 소스 프로그래밍 - NoSQL with Python
오픈 소스 프로그래밍 - NoSQL with Python오픈 소스 프로그래밍 - NoSQL with Python
오픈 소스 프로그래밍 - NoSQL with Python
 
Webinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBWebinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDB
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
Extensible web #html5j
Extensible web #html5jExtensible web #html5j
Extensible web #html5j
 
Introduction to rails
Introduction to railsIntroduction to rails
Introduction to rails
 
How do i Meet MongoDB
How do i Meet MongoDBHow do i Meet MongoDB
How do i Meet MongoDB
 
Pymongo password change made easy
Pymongo password change made easyPymongo password change made easy
Pymongo password change made easy
 
working with PHP & DB's
working with PHP & DB'sworking with PHP & DB's
working with PHP & DB's
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
Laravel level 0 (introduction)
Laravel level 0 (introduction)Laravel level 0 (introduction)
Laravel level 0 (introduction)
 
Integrating Node.js with PHP
Integrating Node.js with PHPIntegrating Node.js with PHP
Integrating Node.js with PHP
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory management
 

Último

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Último (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

PHP client - Mongo db User Group Pune

  • 2. {title : me} ● A Weboniser and a PHP nerd ● MongoDb user ● DevOps ● Love working on Php, and a CakeBaker
  • 3. {title : Content} ● PECL : MongoDb client ● Playing with MongoDb-PHP Client ● Using MongoDB-PHP Client
  • 4. {title : mongoDb-PHP Client} ● Official Library ● Easy and effective to use ● Sweet-Simple-Easy
  • 5. {title : core classes} The Mongo Client The MongoDB Class The Mongo Collection Class The Mongo Cursor Class
  • 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. {title : select database} <?php $connection = new MongoClient(); $db = $connection->dbname; ?> : Be careful for the Database you provide..!
  • 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. {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. {title : finding document} <?php $connection = new MongoClient(); $collection = $connection->meetup->MUGPune; $document = $collection->findOne(); var_dump( $document ); ?>
  • 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. {title : demo app} Created a simple task list manager - http://checklistappmongo-nishant.rhcloud.com/login.php
  • 13. Thanks Would Love to help & answer your queries... Nishant Shrivastava @n1shant nishant-shrivastava