2017-08-22 61 views
0

有人可以幫我這個請。我不斷收到這個錯誤,我不知道爲什麼。 [語義錯誤] line 0,col 75'startDate AS'附近:錯誤:類com \ twcl \ agripayrollBundle \ Entity \ Payrollperiod沒有字段或名爲startDate的關聯。即使在我將其更改爲更正名稱並清除緩存後。班有沒有領域或協會

public function getAllActivePayrollPeriods($em) { 
//  $em = $this->getDoctrine()->getManager(); 
     $repository = $em->getRepository('comtwclagripayrollBundle:Payrollperiod'); 
     $payrollperiods = $repository->createQueryBuilder('p') 
         ->orderBy('p.startdate', 'ASC') 
         ->getQuery()->getResult(); 

     return $payrollperiods; 
    } 

實體

private $startdate; 
public function getStartdate() { 
     return $this->startdate; 
    } 

    public function setStartdate(\DateTime $startdate) { 
     $this->startdate = $startdate; 
    } 
+0

包括你的實體配置的問題,現在我們不能告訴你的實體如何映射到Doctrine,它可能會在'src/AppBundle/Resources/config/doctrine' – naththedeveloper

回答

1

$startdate未映射到該實體。

嘗試將行添加到XML:

<field name="startdate" type="datetime" column="startdate" nullable="false"/> 

然後重新生成實體和更新數據庫架構。 Symfony3:

php bin/console doctrine:generate:entities MyBundle 
php bin/console doctrine:schema:update --force 

的Symfony2:

php app/console doctrine:generate:entities MyBundle 
php app/console doctrine:schema:update --force 

我覺得它更容易使用映射註釋這樣你就可以在同一個文件工作。

+0

當然。或yaml文件。問候 – Albeis

+0

這是一個問題不是映射 – Sue

+0

檢查startDate與D大寫字母。可能是那個? Regards – Albeis