Php 条令何处查询-逻辑顺序-何处(条件1和[条件2或条件3])
我目前正在写一个Shopware插件。Shopware使用条令进行数据库操作 我想写一个这样的条令声明:Php 条令何处查询-逻辑顺序-何处(条件1和[条件2或条件3]),php,doctrine-orm,doctrine,doctrine-query,shopware,Php,Doctrine Orm,Doctrine,Doctrine Query,Shopware,我目前正在写一个Shopware插件。Shopware使用条令进行数据库操作 我想写一个这样的条令声明: Where(condition1 and [condition2 or condition3]) 在代码中查看我的注释 $builder = Shopware()->Models()->createQueryBuilder(); $builder->select([ 'orders', 'details', 'custome
Where(condition1 and [condition2 or condition3])
在代码中查看我的注释
$builder = Shopware()->Models()->createQueryBuilder();
$builder->select([
'orders',
'details',
'customer',
'shipping',
'billing'
]);
$builder->from('Shopware\Models\Order\Order', 'orders');
$builder->leftJoin('orders.details', 'details')
->leftJoin('orders.customer', 'customer')
->leftJoin('orders.shipping', 'shipping')
->leftJoin('orders.billing', 'billing');
//--> Here I would like to write an or statement.
// So that i get all the orders by
// where(customers.email = email) and [(shipping.zipCode = zip) or (billing.zipcode = zip)]
$builder->where('customer.email = :email');
$builder->andWhere('(shipping.zipCode = :zipCode) orWhere (billing.zipCode = :zipCode)');
$builder->setParameter('email', $email);
$builder->setParameter('zipCode', $zip);
$builder->orderBy('orders.id', 'DESC');
$order = $builder->getQuery()->getResult($this->getResultMode());
使用:
除了单个条件外,其中
采用任何形式的条件使用:
除了单个条件外,
其中
采用任何形式的条件是。谢谢这是有效的。我对这个答案很满意:)是的。谢谢这是有效的。我对这个答案非常满意:)
$builder->where('customer.email = :email');
$builder->andWhere('(shipping.zipCode = :zipCode OR billing.zipCode = :zipCode)')