Enviar pesquisa
Carregar
Doctrine MongoDB ODM (PDXPHP)
•
13 gostaram
•
2,100 visualizações
Kris Wallsmith
Seguir
An introduction to MongoDB and the Doctrine MongoDB ODM.
Leia menos
Leia mais
Tecnologia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 49
Baixar agora
Baixar para ler offline
Recomendados
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
Kris Wallsmith
Advanced symfony Techniques
Advanced symfony Techniques
Kris Wallsmith
The Zen of Lithium
The Zen of Lithium
Nate Abele
News of the Symfony2 World
News of the Symfony2 World
Fabien Potencier
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php framework
G Woo
Building Lithium Apps
Building Lithium Apps
Nate Abele
The Origin of Lithium
The Origin of Lithium
Nate Abele
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
Recomendados
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
Kris Wallsmith
Advanced symfony Techniques
Advanced symfony Techniques
Kris Wallsmith
The Zen of Lithium
The Zen of Lithium
Nate Abele
News of the Symfony2 World
News of the Symfony2 World
Fabien Potencier
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php framework
G Woo
Building Lithium Apps
Building Lithium Apps
Nate Abele
The Origin of Lithium
The Origin of Lithium
Nate Abele
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
Dependency Injection IPC 201
Dependency Injection IPC 201
Fabien Potencier
Electrify your code with PHP Generators
Electrify your code with PHP Generators
Mark Baker
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
Hugo Hamon
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Nate Abele
Lithium Best
Lithium Best
Richard McIntyre
The State of Lithium
The State of Lithium
Nate Abele
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
Nubilus Perl
Nubilus Perl
Flavio Poletti
Silex meets SOAP & REST
Silex meets SOAP & REST
Hugo Hamon
Perl Web Client
Perl Web Client
Flavio Poletti
The History of PHPersistence
The History of PHPersistence
Hugo Hamon
Looping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
Mark Baker
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
Fabien Potencier
Database Design Patterns
Database Design Patterns
Hugo Hamon
SPL: The Missing Link in Development
SPL: The Missing Link in Development
jsmith92
Doctrine fixtures
Doctrine fixtures
Bill Chang
Symfony War Stories
Symfony War Stories
Jakub Zalas
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
Jakub Zalas
Speed up your developments with Symfony2
Speed up your developments with Symfony2
Hugo Hamon
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
David Golden
Redis for the Everyday Developer
Redis for the Everyday Developer
Ross Tuck
Mais conteúdo relacionado
Mais procurados
Dependency Injection IPC 201
Dependency Injection IPC 201
Fabien Potencier
Electrify your code with PHP Generators
Electrify your code with PHP Generators
Mark Baker
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
Hugo Hamon
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Nate Abele
Lithium Best
Lithium Best
Richard McIntyre
The State of Lithium
The State of Lithium
Nate Abele
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
Nubilus Perl
Nubilus Perl
Flavio Poletti
Silex meets SOAP & REST
Silex meets SOAP & REST
Hugo Hamon
Perl Web Client
Perl Web Client
Flavio Poletti
The History of PHPersistence
The History of PHPersistence
Hugo Hamon
Looping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
Mark Baker
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
Fabien Potencier
Database Design Patterns
Database Design Patterns
Hugo Hamon
SPL: The Missing Link in Development
SPL: The Missing Link in Development
jsmith92
Doctrine fixtures
Doctrine fixtures
Bill Chang
Symfony War Stories
Symfony War Stories
Jakub Zalas
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
Jakub Zalas
Speed up your developments with Symfony2
Speed up your developments with Symfony2
Hugo Hamon
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
Mais procurados
(20)
Dependency Injection IPC 201
Dependency Injection IPC 201
Electrify your code with PHP Generators
Electrify your code with PHP Generators
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium Best
Lithium Best
The State of Lithium
The State of Lithium
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Nubilus Perl
Nubilus Perl
Silex meets SOAP & REST
Silex meets SOAP & REST
Perl Web Client
Perl Web Client
The History of PHPersistence
The History of PHPersistence
Looping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
Database Design Patterns
Database Design Patterns
SPL: The Missing Link in Development
SPL: The Missing Link in Development
Doctrine fixtures
Doctrine fixtures
Symfony War Stories
Symfony War Stories
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
Speed up your developments with Symfony2
Speed up your developments with Symfony2
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
Semelhante a Doctrine MongoDB ODM (PDXPHP)
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
David Golden
Redis for the Everyday Developer
Redis for the Everyday Developer
Ross Tuck
CodeIgniter Class Reference
CodeIgniter Class Reference
Jamshid Hashimi
The Art of Transduction
The Art of Transduction
David Stockton
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
Vic Metcalfe
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
chuvainc
Crazy things done on PHP
Crazy things done on PHP
Taras Kalapun
Drupal7 dbtng
Drupal7 dbtng
Nicolas Leroy
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
Coding Horrors
Coding Horrors
Mark Baker
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
Chris Reynolds
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)
brian d foy
DBI
DBI
abrummett
究極のコントローラを目指す
究極のコントローラを目指す
Yasuo Harada
Zf Zend Db by aida
Zf Zend Db by aida
waraiotoko
Dependency Injection
Dependency Injection
Rifat Nabi
Database api
Database api
InternetDevels
Php functions
Php functions
JIGAR MAKHIJA
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)
brian d foy
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
brian d foy
Semelhante a Doctrine MongoDB ODM (PDXPHP)
(20)
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
Redis for the Everyday Developer
Redis for the Everyday Developer
CodeIgniter Class Reference
CodeIgniter Class Reference
The Art of Transduction
The Art of Transduction
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
Crazy things done on PHP
Crazy things done on PHP
Drupal7 dbtng
Drupal7 dbtng
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Coding Horrors
Coding Horrors
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)
DBI
DBI
究極のコントローラを目指す
究極のコントローラを目指す
Zf Zend Db by aida
Zf Zend Db by aida
Dependency Injection
Dependency Injection
Database api
Database api
Php functions
Php functions
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
Mais de Kris Wallsmith
Matters of State
Matters of State
Kris Wallsmith
The View From Inside
The View From Inside
Kris Wallsmith
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
Kris Wallsmith
Drupal, meet Assetic
Drupal, meet Assetic
Kris Wallsmith
How Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Kris Wallsmith
Love and Loss: A Symfony Security Play
Love and Loss: A Symfony Security Play
Kris Wallsmith
How Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Kris Wallsmith
Assetic (Zendcon)
Assetic (Zendcon)
Kris Wallsmith
Assetic (OSCON)
Assetic (OSCON)
Kris Wallsmith
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)
Kris Wallsmith
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
Kris Wallsmith
A Practical Introduction to Symfony2
A Practical Introduction to Symfony2
Kris Wallsmith
Symfony 2
Symfony 2
Kris Wallsmith
Symfony in the Cloud
Symfony in the Cloud
Kris Wallsmith
Mais de Kris Wallsmith
(14)
Matters of State
Matters of State
The View From Inside
The View From Inside
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
Drupal, meet Assetic
Drupal, meet Assetic
How Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Love and Loss: A Symfony Security Play
Love and Loss: A Symfony Security Play
How Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Assetic (Zendcon)
Assetic (Zendcon)
Assetic (OSCON)
Assetic (OSCON)
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
A Practical Introduction to Symfony2
A Practical Introduction to Symfony2
Symfony 2
Symfony 2
Symfony in the Cloud
Symfony in the Cloud
Último
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
danishmna97
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
sudhanshuwaghmare1
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Dropbox
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Jeffrey Haguewood
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Zilliz
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
jfdjdjcjdnsjd
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Andrey Devyatkin
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, Adobe
apidays
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Orbitshub
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
apidays
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
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
johnbeverley2021
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Angeliki Cooney
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
apidays
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
rafiqahmad00786416
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
+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@
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
Último
(20)
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
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, Adobe
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
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...
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Doctrine MongoDB ODM (PDXPHP)
1.
Doctrine MongoDB ODM
Kris Wallsmith October 19, 2010
2.
@kriswallsmith •
Symfony Release Manager • Doctrine Team • Senior Software Engineer at • 10 years experience with PHP and web development • Open source evangelist and international speaker
3.
This is MongoDB…
4.
$mongo = new
Mongo(); $db = $mongo->pdxphp; $db->people->save(array( 'name' => 'Kris Wallsmith', ));
5.
$cursor = $db->people->find(); print_r(iterator_to_array($cursor));
6.
Array (
[4cbdffdae84ded424f000000] => Array ( [_id] => MongoId Object [name] => Kris Wallsmith ) )
7.
MongoDB is where
you put your arrays for later.
8.
$db->people->save(array(
'name' => 'Sam Keen', 'roles' => array( 'organizer', 'presenter', ), ));
9.
$query = array('roles'
=> 'presenter'); $cursor = $db->people->find($query); print_r(iterator_to_array($cursor));
10.
Array (
[4cbe03cfe84dedb850010000] => Array ( [_id] => MongoId Object [name] => Sam Keen [roles] => Array ( [0] => organizer [1] => presenter ) ) )
11.
Me too!
12.
$query = array(
'name' => 'Kris Wallsmith', ); $kris = $db->people->findOne($query); $kris['roles'] = array('presenter'); $db->people->save($kris);
13.
$query = array('roles'
=> 'presenter'); $fields = array('name'); $cursor = $db->people->find($query, $fields); print_r(iterator_to_array($cursor));
14.
Array (
[4cbe0a9de84ded7952010000] => Array ( [_id] => MongoId Object [name] => Sam Keen ) [4cbe0a9de84ded7952000000] => Array ( [_id] => MongoId Object [name] => Kris Wallsmith ) )
15.
Be surgical.
16.
$query = array('roles'
=> 'presenter'); $update = array( '$push' => array( 'roles' => 'cool guy', ), ); $db->people->update($query, $update);
17.
Atomic Operators • $inc
• $addToSet • $set • $pop • $unset • $pull • $push • $pullAll • $pushAll • $rename
18.
Advanced Queries
19.
$roles = array('organizer',
'presenter'); $db->people->find(array( 'roles' => array('$all' => $roles), ));
20.
Conditional Operators • $ne
• $size • $in • $exists • $nin • $type • $mod • $or • $all • $elemMatch
21.
Cursor Methods
22.
$cursor = $db->people->find(); $cursor->sort(array('name'
=> 1)); foreach ($cursor as $person) { // ... }
23.
I like you,
Sam.
24.
$samRef = MongoDBRef::create('people',
$samId); $db->people->update( array('_id' => $kris['_id']), array( '$addToSet' => array( 'likes' => $samRef, ), ) );
25.
$sam = $db->getDBRef($samRef);
26.
$db->people->find(array(
'likes.$id' => $kris['_id'], ));
27.
Terminology RDBMS
MongoDB Database Database Table Collection Row Document Foreign Key Database Reference
28.
A document is
an array.
29.
Arrays are nice.
30.
Objects are better.*
* Whenever objects are better.
31.
The Doctrine MongoDB Object
Document Mapper maps documents to and from objects.
32.
We just need
to tell it how.
33.
/** @Document(collection="people") */ class
Person { /** @Id */ public $id; /** @String */ public $name; /** @Collection */ public $roles = array(); /** @ReferenceMany */ public $likes = array(); /** @EmbedMany(targetDocument="Address") */ public $addresses = array(); }
34.
POPO FTW!
35.
$kris = new
Person(); $kris->name = 'Kris Wallsmith'; $kris->roles[] = 'presenter'; $kris->likes[] = $sam; $kris->addresses[] = $homeAddy; $documentManager->persist($kris); $documentManager->flush();
36.
Wherefore art thou
->save() ?
37.
Documents Controller
Document Manager
38.
39.
ActiveRecord is more
abstract.
40.
Doctrine calculates the optimal
query for you.
41.
$kris = $dm->findOne('Person',
array( 'name' => 'Kris Wallsmith', )); $kris->roles[] = 'cool guy'; $dm->flush();
42.
$db->people->update(array(
'_id' => $kris->id, ), array( '$push' => array( 'roles' => 'cool guy', ), ));
43.
Query API
44.
$query = $dm->createQuery('Person')
->field('name')->notEqual('Kris Wallsmith') ->field('roles')->equals('presenter') ->sort('name', 'asc'); $cursor = $query->execute();
45.
Lifecycle Callbacks
46.
/** @Document @HasLifecycleCallbacks
*/ class Foo { /** @Timestamp */ public $createdAt; /** @PrePersist */ public function ensureCreatedAt() { $this->createdAt = new DateTime(); } }
47.
OpenSky is Hiring!
http://engineering.shopopensky.com Please contact me if you're interested.
48.
OpenSky is Hiring!
http://engineering.shopopensky.com Please contact me if you're interested.
49.
mongodb.org doctrine-project.org symfony-reloaded.org
Baixar agora