教义or Where inside and Where
Posted
技术标签:
【中文标题】教义or Where inside and Where【英文标题】:doctrine orWhere inside andWhere 【发布时间】:2015-10-02 19:54:52 【问题描述】:如何使用学说指定搜索多列?
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('id', $id))
->andWhere($criteria->expr()->eq('active', true));
$search = "Abc";
if (!empty($search))
$criteria->andWhere(
$criteria->expr()->contains('column1', $search) ||
$criteria->expr()->contains('column2', $search)
);
【问题讨论】:
【参考方案1】:使用orX()
:
$criteria->andWhere(
$criteria->expr()->orX(
$criteria->expr()->contains('column1', $search),
$criteria->expr()->contains('column2', $search)
)
);
【讨论】:
以上是关于教义or Where inside and Where的主要内容,如果未能解决你的问题,请参考以下文章