Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 条令何处查询-逻辑顺序-何处(条件1和[条件2或条件3])_Php_Doctrine Orm_Doctrine_Doctrine Query_Shopware - Fatal编程技术网

Php 条令何处查询-逻辑顺序-何处(条件1和[条件2或条件3])

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

我目前正在写一个Shopware插件。Shopware使用条令进行数据库操作

我想写一个这样的条令声明:

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)')