2 回答
TA贡献1829条经验 获得超4个赞
使用 Doctrine 你可以这样做:
$queryBuilder = $this->createQueryBuilder('request');
$queryBuilder
->andWhere($queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('user.speakFrench', ':speakFrench'),
$queryBuilder->expr()->like('request.name', ':name'),
$queryBuilder->expr()->in('request.state', ':states'),
$queryBuilder->expr()->in('request.job', ':jobs'),
))
->setParameter('speakFrench', true)
->setParameter('name', 'Martin')
->setParameter('states', ['Ohio', 'Texas'])
->setParameter('jobs', ['Photographer', 'Reporter'])
->getQuery()
->getResult();
这应该是一个好的开始。
TA贡献1844条经验 获得超8个赞
以下似乎是符合您要求的有效查询:
SELECT *
FROM application
WHERE SPEAK_FRENCH = 1
AND NAME = "Martin"
AND STATE = IN("Ohio","Texas")
AND (JOB LIKE "%Photographer%" OR JOB LIKE "%Reporter%");
- 2 回答
- 0 关注
- 114 浏览
添加回答
举报