尝试使用FOSUserBundle创建新用户时未找到列的异常

时间:2014-05-06 12:00:52

标签: symfony fosuserbundle

当我尝试插入新的用户实体时,我的应用程序抛出以下异常:

  

执行' SELECT t1.username AS时发生异常   username2,t1.username_canonical AS username_canonical3,t1.email AS   email4,t1.email_canonical AS email_canonical5,t1.enabled AS   enabled6,t1.salt AS salt7,t1.password AS password8,t1.last_login AS   last_login9,t1.locked AS locked10,t1.expired AS expired11,   t1.expires_at AS expires_at12,t1.confirmation_token AS   confirmation_token13,t1.password_requested_at AS   password_requested_at14,t1.roles AS roles15,t1.credentials_expired   AS credentials_expired16,t1.credentials_expire_at AS   credentials_expire_at17,t1.id AS id18,t1.nom AS nom19 FROM etudiant   t1 WHERE t0.username_canonical =?'与params [" dar"]:

     

SQLSTATE [42S22]:找不到列:1054未知列   ' t0.username_canonical'在' where子句'

用户:

<?php

namespace Esprit\UserBundle\Entity;
use Esprit\UserBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="Student ")
*/
 class Student extends User
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

 /**
 *@ORM\Column(type="string",length=255)
 */

private $nom;

}

config.yml:

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
     user_class: Esprit\UserBundle\Entity\Student

如何解决此问题?

2 个答案:

答案 0 :(得分:2)

您需要使用以下内容声明User类的鉴别器:

 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"student" = "Student", "employee" = "Employee"})

答案 1 :(得分:-1)

所以我解决了这个问题,我们应该从BaseUser扩展

class Student extends BaseUser
{

}