That doesn't make too much sense to me, although, it might work!! public function load($em) <-- $em { $user1 = new User(); $user1->setName('Cesar Hernandez'); $dm = $this->get('doctrine.odm.mongodb.document_manager'); <-- $dm $dm->persist($user);
from your command let's say: console doctrine:mongodb:daba:load .... you are passing the entity manager, in this case document-manager to de load function through $em parameter (better to be renamed as $manager) and the use it later like this. $manager->persist($user) $manager->flush() but as I said before, it might work as you retrieve $dm from DIC which I don't know whether it's available from load command... Hope it helps On Mar 26, 10:49 pm, César Hernández <dpce...@gmail.com> wrote: > in ORM with the command: > php app/console doctrine:data:load > > y initial data in the database > that I have defined in the folder ...Bundle/DataFixtures/ORM / > > My question is, how do the same with ODM? > en route > MiEmpresa\MiPrimerNOSQLBundle\DataFixtures/ODM > I have the following code > > <?php > > namespace MiEmpresa\MiPrimerNOSQLBundle\Controller; > > use Symfony\Bundle\FrameworkBundle\Controller\Controller; > use MiEmpresa\MiPrimerNOSQLBundle\Document\User; > > class Loadclientes implements FixtureInterface > { > public function load($em) > { > $user1 = new User(); > $user1->setName('Cesar Hernandez'); > $dm = $this->get('doctrine.odm.mongodb.document_manager'); > $dm->persist($user); > > $user2 = new User(); > $user2->setName('May-lhing Sanchez'); > $dm = $this->get('doctrine.odm.mongodb.document_manager'); > $dm->persist($user); > > $user3 = new User(); > $user3->setName('Sebastian Hernandez Sanchez'); > $dm = $this->get('doctrine.odm.mongodb.document_manager'); > $dm->persist($user); > > $dm->flush(); > } > > } > > but when I run > php app/console doctrine:data:load > me the following error > > PHP Fatal error: Class > 'Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand' not found in > /var/www/sf2-pr8-02/vendor/symfony/src/Symfony/Bundle/DoctrineMongoDBBundle/Command/DropSchemaDoctrineODMCommand.php > on line 27 > > Fatal error: Class > 'Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand' not found in > /var/www/sf2-pr8-02/vendor/symfony/src/Symfony/Bundle/DoctrineMongoDBBundle/Command/DropSchemaDoctrineODMCommand.php > on line 27 > > An additional comment > to prepare my portfolio work > run the following commands > > git clonehttps://github.com/symfony/symfony-standard.gitsf2-pr8-01 > cd sf2-pr8-01 > ./bin/vendors.sh > ./bin/build_bootstrap.php > php app/console assets:install web/ > cd vendor > git clonehttps://github.com/doctrine/mongodb.gitdoctrine-mongodb > git clonehttps://github.com/doctrine/mongodb-odm.git doctrine-mongodb > > Some oriención about ....? > data: load only for ORM? > if not with "data: load" there is a "best practice" to load initial data in > ODM? > > Waiting for their comments on > Greetings ...! > -- > César Hernández > Anzoátegui - Venezuela > dpce...@gmail.com > > LinuxCounter: 285.345 > CIV: 122.539 -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en