나는 동등하지 않은 조건을 얻을 수 없습니다. cancelled_by
필드가 null
이므로 모든 데이터가 무시됩니다. cancelled_by
필드가 null
인 경우이 값은 Tutor
과 동일하지 않습니다.은 cakephp3에서 작동하지 않습니다.
이 작은 오류로 인해 5 일 동안 잘못된 데이터가 발생했습니다. 내가 만들고있는 실수가 있니? 등호 조건을 제거하면 모든 데이터가 예상대로 검색됩니다.
아래의 2 줄은 내가 사용했거나 작동하지 않은 것입니다.
'Lessons.cancelled_by not like' => '%Tutor%'
'Lessons.cancelled_by !=' => 'Tutor'
$searchDate = date('Y-m-d');
$query3 = $this->find()
->contain([
'Tutors', 'Subjects', 'Students', 'Students.Guardians', 'XeroInvoices'
])
->select([
'Lessons.id', 'Lessons.lesson_date', 'Lessons.start_time', 'Lessons.end_time',
'Tutors.id', 'Tutors.first_name', 'Guardians.id', 'Tutors.last_name',
'Lessons.timesheet_status', 'Students.id', 'Students.first_name',
'Students.last_name', 'Students.has_credit', 'XeroInvoices.invoice_number',
'Guardians.guardian_email', 'Guardians.guardian_mobile',
'Guardians.guardian_last_name', 'Guardians.guardian_first_name',
'Lessons.due_date', 'Lessons.cancelled_by', 'Subjects.name', 'Lessons.revenue',
'Lessons.discount', 'Lessons.surcharge', 'Lessons.future_makeup_lesson_id',
'Lessons.cancelled_pastlesson_id'
])
->where([
'Lessons.due_date' => $searchDate,
'Lessons.lesson_inactive' => false,
'Students.has_credit like' => '%postpaid%',
'Lessons.cancelled_by !=' => 'Tutor'
])
->order([
'Guardians.id',
'Lessons.lesson_date' => 'ASC',
'Lessons.start_time' => 'ASC'
])
->hydrate(false);
평등 연산자는 일반적으로 SQL에서 null 값과 잘 상호 작용하지 않습니다. 아마도 'cancelled_by IS'=> NULL' 또는 'IS NOT'을 적절하게 사용하여 "OR"조건을 추가해야합니다. –
이것은 PHP와는 관련이 없습니다. SQL 언어에서 'NULL'은 정의상 아무 것도 아닙니다. –
내가 문제를 이해한다면 도움을 요청하지 않을 것이며, cakephp3에 게시하지 않을 것입니다. – jagguy