1
我想給一個變量放到查詢的字段名,所以我有一個模式:Doctrine2 QueryBuilder的 - 在字段名變量
id amazon - tesco - asda - happyshopper -
1 £5 - NULL - NULL - £4.99
2 NULL - £2.99 - NULL - NULL
然後
$store = 'amazon';
$qb = $em->createQueryBuilder();
$products = $qb->select('p')->from('MyBundle:Product', 'p')
->where('p.:store IS NOT NULL')
->setParameter('store', $store)
->add('orderBy', 'p.onSale DESC')
->setMaxResults(40)
->getQuery()
->getResult();
將返回行1.
我所做的:
->where('p.:store IS NOT NULL')
->setParameter('store', $store)
錯誤,錯誤。
->where(':store IS NOT NULL')
->setParameter('store', $store)
沒有錯誤,但不適用存儲過濾器。
這就是我的下一份工作,整理出結構!謝謝。 – BobFlemming