DoctrineFixturesBundle icon indicating copy to clipboard operation
DoctrineFixturesBundle copied to clipboard

Saved data disapears.

Open e-v-medvedev opened this issue 5 years ago • 1 comments

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:[email protected]: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 avatar May 20 '20 09:05 e-v-medvedev

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.

e-v-medvedev avatar May 20 '20 15:05 e-v-medvedev