2016-07-05 3 views
2

部分オブジェクトを選択し、そのプロパティの1つにABS関数を適用する次のクエリがあります。私は結果を得たが、私は小枝のテンプレートでレンダリングにエラーがあります。私は私の小枝のことわざにエラーが発生しましたDoctrine Symfonyの部分プロパティに関数を適用する

public function findAll($params = null) 
{ 
    $qb = $this->createQueryBuilder('coa') 
    -->select('PARTIAL coa.{id, accountCode, description, normal, createdAt}', 'ABS(coa.accountCode) as abs', 'at') 
    ->join('coa.accountType', 'at'); 

    if (!empty($params)) { 
     if (!empty($params['accountCode'])) { 
      $qb->andWhere("REGEXP(:accountCode, coa.accountCode) = 1") 
      ->setParameter('accountCode', '[[:<:]](' . preg_quote($params['accountCode']) . ')'); 
     } 

     if (!empty($params['description'])) { 
      $qb->andWhere("REGEXP(:description, coa.description) = 1") 
      ->setParameter('description', '[[:<:]](' . preg_quote($params['description']) . ')'); 
     } 

     if (!empty($params['normal'])) { 
      $qb->andWhere('coa.normal = :normal') 
      ->setParameter('normal', $params['normal']); 
     } 

     if (!empty($params['accountType'])) { 
      $qb->andWhere('at.id = :accountTypeId') 
      ->setParameter('accountTypeId', $params['accountType']->getId()); 
     } 

     if (!is_null($params['status'])) { 
      $qb->andWhere('coa.active = :status') 
      ->setParameter('status', $params['status']); 
     } 
    } else { 
     $qb->andWhere('coa.active = 1'); 
    } 

    //$qb->orderBy('ABS(coa.accountCode)', 'ASC'); 

    return $qb->getQuery(); 
} 

:そうのようにキーを持つアレイの

キー "ID" "0、ABSは" CIAccountingBundleに存在しません:ChartOfAccounts:indexContent.html。

<li><a href="{{ path('chartofaccounts_show', { 'id' : entity.id }) }}">{{ FAIcon('search-plus') }} View</a></li> 

エラーMEAを何:ラインで小枝28

これはライン28でありますn?私は選択に誤りがあると思うし、私は正しい方法を理解することができません。

ありがとうございます!あなたは2つのことを選択されているクエリで

答えて

1

  • 部分オブジェクト
  • 各エンティティの腹筋

を、あなたは配列になる: - キー0:エンティティ - キーabs:abs

あなたのtwigテンプレートでentity.idをentity [0] .idに置き換えるとうまくいくはずです。

+0

ありがとうございました! – iamjc015

関連する問題