of 68 /68
hello $Mongo Introduction à MongoDB Gérald Croës http://croes.org/gerald/blog/ @geraldcroes Cédric Derue @cderue http://www.croes.org/gerald/conf/php/lille/2011/helloMongo.pdf

Hello mongo

Embed Size (px)

Text of Hello mongo

  • 1. hello $MongoIntroduction MongoDBGrald Croshttp://croes.org/gerald/blog/@geraldcroesCdric [email protected]://www.croes.org/gerald/conf/php/lille/2011/helloMongo.pdf

2. Il est encore temps de quitterla salle... Pas de schma Non transactionnel Pas de jointures Pas de contrainte dintgrit Pas de SQL Peu dintgration avec des outils dentreprise Limit 2Go PHPTourConferencier:fields:id:type: idid: truenom:type: stringprenom:type: stringentreprise:type: string 59. DocumentManager : initialisation$config = new DoctrineODMMongoDBConfiguration();$config->setProxyDir(path/to/geearate/proxies);$config->setProxyNamespace(Proxies);$config->setHydratorDir(path/to/generate/hydrators);$config->setHydratorNamespace(Hydrators);$reader = new DoctrineCommonAnnotationsAnnotationReader();$reader->setDefaultAnnotationNamespace(DoctrineODMMongoDBMapping);$config->setMetadataDriverImpl(new AnnotationDriver($reader));$dm = DoctrineODMMongoDBDocumentManager::create(new Mongo(), $config); (), $config); 60. DocumentManager Accs central de la persistance des donnes Implemente le pattern Unif Of Work Gestion de ltat des objets en mmoire (NEW,MANAGED, DETACHED ou REMOVED) 61. Requtes avec Doctrine// SELECT ALL$conferences = $dm->getRepository(PHPTourConference)->findBy(array());// SELECT BY ID$conference = $dm->find( PHPTourConference, $id);// SELECT BY CRITERIA$conference = $dm->getRepository(PHPTourConference)->findOneBy(array(titre => Hello $Mongo));// INSERT OR UPDATE$dm->persist($conference);// DELETE$dm->remove($conference); 62. GridFS$conference = $dm->createQueryBuilder(PHPTourConference)->field(titre)->equals(hello $Mongo;)->getQuery()->execute()->getSingleResult();header(Content-type: application/pdf);echo $conference->getSlides()->getFichier()->getBytes(); 63. Performances - Indexesbd.Collection.ensureIndex({monChamp : 1})bd.Collection.dropIndex()bd.Collection.dropIndex({monChamp : 1}) Opration coteuse et bloquante Peut tre ralise en tche de fonddb.Collection.ensureIndex({monChamp : 1},{background : 1}) 64. Performances - Indexes (2) Index sur plusieurs champsdb.ensureIndex({nom : 1, prenom : 1}); Assurer lunicitdb.ensureIndex({nom : 1, prenom : 1},{unique : 1}); 65. Performances - Indexes (3)Pas toujours efficaces ngations ($ne, $not, ...) Oprations arythmtiques ($mod, ...) Map / Reduce (boite noire pour loptimiseur) La plupart des expressions rationelles (/a/) 66. Outils dev. et admin. RockMongo Fang of Mongo MongoExplorer (silverlight) MongoHub PHPMoAdmin Meclipse MongoVue 67. Questions ?https://github.com/geraldcroes/MongoConference/ 68. PhotographiesHangin by a thread - http://www.500px.com/photo/3159488 - Scott SmoraPacific coast rail line - http://www.500px.com/photo/1739071 - LachlanCrossroads - http://500px.com/photo/206202 - DMitry KotOld book - http://500px.com/photo/841759 - Amar ChauhanInappropriately Dressed - White dress fast bike - http://500px.com/photo/330960 - Apollinaria Tolorayajunction - http://500px.com/photo/3113517 - Kai Ziehlthe cube - http://500px.com/photo/1365861 - Stephen L.Sans titre - http://500px.com/photo/1125283 - James TatumWhats in the box?- http://500px.com/photo/1292897 - Andrew Dogears of war - http://500px.com/photo/672778 - Dave KaneLink - http://500px.com/photo/514318 - Djura Stankovic PhotographyRussian dolls lined up - http://www.flickr.com/photos/sunnyuk/3240916291/ - sunnyUKrecords - http://500px.com/photo/1084138 - Jackson Carsonmicrophone - http://www.500px.com/photo/1910034 - Tchon T