Hello!
I’ve tried to set a DQL query using QueryBuilder but so far no good…
The query I’d like to have looks like this:
$queryBuilder = Zend_Registry::get('entityManager')->createQueryBuilder();
$queryBuilder->select('s.*');
$queryBuilder->from('GPos_Model_Sale', 's');
$queryBuilder->where('s.store = ?', $authNamespace->store); //breaks on this line
$queryBuilder->andWhere('s.seller = ?', $seller->getId());
$queryBuilder->andWhere('((s.date >= ?', $dateStart);
$queryBuilder->andWhere('s.date <= ?', $dateEnd);
$queryBuilder->andWhere('s.status = "closed") OR s.status = "onhold")');
$queryBuilder->groupby('s.id');
return $queryBuilder->getQuery()->getResult();
Note: I know I could use the ->andWhere etc one after another but it was just for XDebug purpose.
Note2: $authNamespace->store stands for a GPos_Model_Store entity’s ID.
Anyways, I get an Exception on $queryBuilder->where('s.store = ?', $authNamespace->store) stating : “Expression of type ” not allowed in this context.”
I tried using an entity itself instead but then I received a “Expression of type ‘GPos_Model_Store’ not allowed in this context.” exception…
Can any of you point out what I’m doing wrong here ?
Thank you!
Found my mistake.
Changed my query to:
And now it works like a charm.