Doctrine Request Error

Very strange. I used this method from the teachings hundreds of times. I have a simple controller that takes id as a parameter. The request generated by Doctrine is erroneous and failed.

/**
 * @Security("has_role('ROLE_ADMIN')")
 * @return Response
 */
public function editSellerAction($id)
{
    $em  = $this->getDoctrine()->getManager();
    $seller = $em->getRepository('SiteUserBundle:Seller')->find($id);

    // ...
    $form = $this->createForm(new SellerType(), $seller, array(
        'method' => 'POST'
    ));
    // ...
}

The generated request is as follows

[2/2] DBALException: An exception occurred while executing 'SELECT t1.id AS id2, t1.username AS username3, t1.password AS password4, t1.firstname AS firstname5, t1.lastname AS lastname6 FROM seller t1 WHERE t0 .id = ? LIMIT 1 'with parameters ["2"]:

SQLSTATE [42S22]: Column not found: 1054 Unknown column 't0.id' in 'where clause' +

, "WHERE t0.id", "WHERE t1.id". t1, phpmyadmin, .

, ?

/**
 * Seller have access to their customer and are able to RW access to the customers
 *
 * @ORM\Table("seller")
 * @ORM\Entity
 * @author Michael Villeneuve
 */
class Seller extends User
{

    /**
     * @var array
     * 
     * @ORM\OneToMany(targetEntity="Customer", mappedBy="seller", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="seller_id", referencedColumnName="id")
     **/
    protected $customers; 

    /**
     * @var string
     *
     * @ORM\Column(name="firstname", type="string", length=255, nullable=false)
     */
    protected $firstname;

    /**
     * @var string
     *
     * @ORM\Column(name="lastname", type="string", length=255, nullable=false)
     */
    protected $lastname;

    // Other attributes and only getters/setter


/**
 *
 * @ORM\Entity
 */
class User implements UserInterface
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255, unique=true)
     */
    private $username;

    /**
     * @ORM\Column(type="string", length=64)
     */
    private $password;

3 , (, ).

+4
3

2 :

  • abstract . , . , . , BaseEntity ID . extend ID. , .
  • - . User . .

, , .

+2

id Seller

/**
 * Seller have access to their customer and are able to RW access to the customers
 *
 * @ORM\Table("seller")
 * @ORM\Entity
 */
class Seller extends User
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var array
     * 
     * @ORM\OneToMany(targetEntity="Customer", mappedBy="seller", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="seller_id", referencedColumnName="id")
     **/
    protected $customers; 

    /**
     * @var string
     *
     * @ORM\Column(name="firstname", type="string", length=255, nullable=false)
     */
    protected $firstname;

    /**
     * @var string
     *
     * @ORM\Column(name="lastname", type="string", length=255, nullable=false)
     */
    protected $lastname;

    // Other attributes and only getters/setter


/**
 *
 * @ORM\Entity
 * @author Michael Villeneuve<michael@panierdachat.com>
 */
class User implements UserInterface
{

    /**
     * @ORM\Column(type="string", length=255, unique=true)
     */
    private $username;

    /**
     * @ORM\Column(type="string", length=64)
     */
    private $password;
0

Source: https://habr.com/ru/post/1525109/


All Articles