-
-
Save tyx/353de6d6aaf367abd6e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$em = $this->getContainer()->get('doctrine')->getManager(); | |
$a = new \Rezzza\VlrModelBundle\Entity\CityTimezone(); | |
$a->setIdentifier('test a'); | |
$a->setGmtoffset(1); | |
$a->setDstoffset(2); | |
$a->setRawoffset(3); | |
$class = get_class($a); | |
$metadata = $em->getClassMetaData($class); | |
$generatorType = $metadata->generatorType; | |
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); | |
$reflection = new \ReflectionClass($class); | |
$property = $reflection->getProperty('id'); | |
$property->setAccessible(true); | |
$property->setValue($a, $id); | |
$em->persist($a); | |
$em->flush(); | |
$em->clear(); | |
$metadata->setIdGeneratorType($generatorType); | |
$b = new \Rezzza\VlrModelBundle\Entity\CityTimezone(); | |
$b->setIdentifier('test b'); | |
$b->setGmtoffset(1); | |
$b->setDstoffset(2); | |
$b->setRawoffset(3); | |
$em->persist($b); | |
$em->flush(); | |
$em->clear(); | |
// Throw | |
// [Doctrine\DBAL\DBALException] | |
// An exception occurred while executing 'INSERT INTO city_timezone (identifier, gmtoffset, dstoffset, rawoffset, id) VALUES (?, ?, ?, ?, ?)' with params ["test b", 1, 2, 3]: | |
// SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment