A few minutes ago I found an error in Doctrine2.
I added some fields in my entity, then refresh the mysql table and going to persist ago I noticed that the new data is not stored in the table.
Tried a var_dump the value of "->getXXX()" and the result was correct.
Here is the code used:
$user->setName($name);
$user->setSurname($surname);
if($country)
$user->setCountry($country->getId());
//New code
if($province > 0)
$user->setProvince($province);
if($town > 0)
$user->setTown($town);
var_dump($user->getProvince(), $user->getTown()); //Works OK
$em->persist($user); // Only persists values before Province.
$em->flush();
Thank's and regards!
Edited
Information about my Entity:
class Users
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=50)
*/
private $name;
/**
* @var string $surname
*
* @ORM\Column(name="surname", type="string", length=95)
*/
private $surname;
/**
* @var string $mail
*
* @ORM\Column(name="mail", type="string", length=80, unique=true)
*/
private $mail;
/**
* @var string $password
*
* @ORM\Column(name="password", type="string", length=255)
*/
private $password;
/**
* @var $country
*
* @ORM\Column(name="country", type="integer")
*/
private $country;
/**
* @var $province
*
* @ORM\Column(name="province", type="integer")
*/
private $province;
/**
* @var $town
*
* @ORM\Column(name="town", type="integer")
*/
private $town;
}
Country, province and town are id's from tables with the same names. I've tried to change the type of the field with a ManytoOne assosiation, but it gets me an error on the Doctrine2 generated SQL. It's seem to be a cache error, but I can't solve it.