执行查询时出现异常,在Symfony 2.3中找不到该列

时间:2014-07-07 07:29:57

标签: symfony command-line doctrine-orm symfony-2.3

通过命令行执行命令时,我发现此错误"列未找到"

    [Doctrine\DBAL\DBALException]                                                                                                                
  An exception occurred while executing 'SELECT t0.id AS id1, t0.first_name AS first_name2, t0.last_name AS last_name3, t0.email AS email4, t  
  0.gender AS gender5, t0.is_active AS is_active6, t0.vote_count AS vote_count7, t0.created_at AS created_at8, t0.updated_at AS updated_at9,   
  t0.fbUserId AS fbUserId10, t0.username AS username11, t0.password AS password12, t0.salt AS salt13 FROM users t0 WHERE t0.is_active = ?' wi  
  th params [0]:                                                                                                                               
  SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.fbUserId' in 'field list'                                                         

  [PDOException]                                                                        
  SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.fbUserId' in 'field list' 

任何想法为什么只能通过命令行我收到此错误。

3 个答案:

答案 0 :(得分:3)

可能您忘记更新架构,如果是,请更新架构..

答案 1 :(得分:0)

对于版本Symfony> 2.7使用:

  

php bin / console doctrine:schema:update --force

对于版本Symfony< 2.7使用:

  

php app / console doctrine:schema:update --force

答案 2 :(得分:0)

由于您未根据模型更新数据库架构,因此发生错误。使用以下命令更新架构:

         php app/console doctrine:schema:update --force

或使用以下命令进行上层版本(> 2.8)

         php bin/console doctrine:schema:update --force