SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
@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

Mais conteúdo relacionado

Mais procurados

DomDisc and the Domino data api
DomDisc and the Domino data apiDomDisc and the Domino data api
DomDisc and the Domino data api
Jens Bruntt
 

Mais procurados (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
 

Destaque

Destaque (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
 

Semelhante a PHP client - Mongo db User Group Pune

Integrating Node.js with PHP
Integrating Node.js with PHPIntegrating Node.js with PHP
Integrating Node.js with PHP
Lee Boynton
 

Semelhante 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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

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