这是我的疑问:
SELECT * FROM mytable WHERE `USER` = '1599' AND `id` = '124253' AND `wednesday` IS NULL
这是php代码:
$check = Test::model()->find("id =:id and user =:user and ".$day." =:day ", array(":id" => $check_lunch_per_day, ":user" => $user, 'day'=> null));
另一次尝试:
$check = Test::model()->find("id =:id and user =:user and ".$day." =:day ", array(":id" => $check_lunch_per_day, ":user" => $user, 'day'=> 'IS NULL'));
但检查结果始终为空。我该怎么办?如果它为null,我想得到星期三列值。
答案 0 :(得分:0)
这应该有效,
将:day
设为IS NULL
$check = Test::model()->find("id =:id and user =:user and ".$day." =:day ",
array(":id" => $check_lunch_per_day, ":user" => $user, ':day'=> 'IS NULL'));