I am new to doctrine. I have a following User class with annotations. The primary key is $userid, which is string. Instead of setting the $userid automatically, I want to set the id manually. How ever I am not sure how to do that?
<?php
namespace models;
/**
* User
*
* @Table(name="user")
* @Entity
*/
class User
{
/**
* @var string $userid
*
* @Column(name="userid", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
* @Id
* @GeneratedValue(strategy="IDENTITY")
*/
private $userid;
/**
* @var string $fullname
*
* @Column(name="fullname", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $fullname;
/**
* @var string $password
*
* @Column(name="password", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $password;
/**
* @var string $email
*
* @Column(name="email", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $email;
/**
* Get userid
*
* @return string $userid
*/
public function getUserid()
{
return $this->userid;
}
/**
* Set fullname
*
* @param string $fullname
*/
public function setFullname($fullname)
{
$this->fullname = $fullname;
}
/**
* Get fullname
*
* @return string $fullname
*/
public function getFullname()
{
return $this->fullname;
}
/**
* Set password
*
* @param string $password
*/
public function setPassword($password)
{
$this->password = $password;
}
/**
* Get password
*
* @return string $password
*/
public function getPassword()
{
return $this->password;
}
/**
* Set email
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* Get email
*
* @return string $email
*/
public function getEmail()
{
return $this->email;
}
}
If I even make the id public and set it myself, the doctrine 2 still inserts the default value, which is empty string, leading to Integrity constraint violation. Can someone provide me detailed solution for this.