I have a problem, I have a table (downloads) with two fields: Token (primary key) and value.
I have my entity Downloads with these methods (only show token methods, value works right):
/**
* @var string
*
* @ORM\Column(name="token", type="string", length=45, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $token;
/**
* Set token
*
* @param string $token
* @return Downloads
*/
public function setToken($token)
{
$this->token = $token;
return $this;
}
/**
* Get token
*
* @return string
*/
public function getToken()
{
return $this->token;
}
But, when I do this in my controller:
$em = $this->getDoctrine()->getManager();
$Download = new Downloads();
$Download->setToken($token);
$Download->setValid($now);
$em->persist($Download);
$em->flush();
Object is well created, but in my database Valid is stored correctly, and token is store empty!!
if I see the values, util $em->flush(); object download has two correct values, but after this, token (primary key) disappear his value.
How can I do?