0
此查询并不按预期工作。会发生什么事情,它会选择与评估一词在其中的记录。我已经尝试了一些变化,但正如你所看到的,查询只能得到'数学'这个词的记录,并且不包含'奖学金'和'评估'的记录。在cakephp3中获取2条不同条件的记录
我不能得到这个在cakephp3工作。会发生什么是我得到评估或奖学金的记录。
$subjectMaths = $this->Students->Subjects->find('list')
->select(['id', 'name'])
->where([
'Subjects.name not LIKE' => '%assessment%' ,
'Subjects.name LIKE' => '%maths%',
'Subjects.name not LIKE' => '%scholarship%'
])
->order(['Subjects.name' => 'asc']);
$subjectMaths = $this->Students->Subjects->find('list')
->select(['id', 'name'])
->where([
'Subjects.name LIKE' => '%maths%',
'OR'=> [
['Subjects.name not LIKE' => '%assessment%' ],
[ 'Subjects.name not LIKE' => '%scholarship%',]
]
])
->order(['Subjects.name' => 'asc']);