doctrine / DoctrineFixturesBundle

Symfony integration for the doctrine/data-fixtures library
MIT License
2.45k stars 202 forks source link

Saved data disapears. #319

Open e-v-medvedev opened 4 years ago

e-v-medvedev commented 4 years ago

The same code works fine outside the FixturesBundle and does't work inside it. For example:

$row = new Smartceo\MUnitBundle\Entity\MUnit(); $row->setCode("sd") ->setLabel("sdfs") ->setName("test") ->setGroup("test"); $manager->persist($row); $manager->flush();

This code with simple entity works with entity manager created this way:

$isDevMode = true; $proxyDir = null; $cache = null; $useSimpleAnnotationReader = false; $config = Setup::createAnnotationMetadataConfiguration(array(DIR."/src"), $isDevMode, $proxyDir, $cache, $useSimpleAnnotationReader); // or if you prefer yaml or XML //$config = Setup::createXMLMetadataConfiguration(array(DIR."/config/xml"), $isDevMode); //$config = Setup::createYAMLMetadataConfiguration(array(DIR."/config/yaml"), $isDevMode);

$connectionParams = array( 'url' => 'mysql://root2:some_pass@127.0.0.1:3306/smartceo_bpm', ); $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams); // obtaining the entity manager $manager = EntityManager::create($conn, $config);

But doesn't work inside this:

class SomeclassFixtures extends Fixture implements FixtureGroupInterface { public function load(ObjectManager $manager) { } }

No php or mysql error messages found. $row->getId() returns null before manager->flush() and int value after flushing as expected. But i can not found record with Mysql Workbench. How can it happend.

e-v-medvedev commented 4 years ago

Problem found. With Doctrine\ORM\EntityManager everything works fine, with Doctrine\Common\Persistence\ObjectManager - not. Some times the last one works as expected, but i do not understend why.