これはクエリでFIND_IN_SETを使用する方法です。クエリで自動的にIS NULLを追加し、 WHERE s
。私は$this->db->last_query()
を使用してクエリを印刷するときcat_id
= '11' ANDクエリFIND_IN_SET自動的にcodeigniterのクエリにIS NULLを追加し、グループ内にクエリを括弧で追加する必要があります
$spilt=explode(',',$newstyle);
foreach ($spilt as $splitkey => $splitvalue) {
if ($splitkey == 0) {
$this->db->where("FIND_IN_SET(".$splitvalue.",w_card_style)");
}
else{
$this->db->or_where("FIND_IN_SET(".$splitvalue.",w_card_style)");
}
}
、それは各FIND_IN_SET後
SELECT `c`.`city_name`, `s`.`name`, `s`.`location`, `s`.`starting_price`, `s`.`budget_range`, `s`.`cat_id`, `s`.`id`, `i`.`path`, `s`.`specification_status`, `s`.`per_unit_charge`, `s`.`w_card_style`, `s`.`w_card_style`, `s`.`budget_range` FROM `image_gallery` as `i` JOIN `specification` as `s` ON `i`.`ser_id`=`s`.`id` JOIN `cities` as `c` ON `c`.`city_id`=`s`.`location` JOIN `wcard_style` as `ws` ON `ws`.`id`=`s`.`w_card_style` WHERE `s`.`cat_id` = '11' AND FIND_IN_SET(1,w_card_style) IS NULL OR FIND_IN_SET(2,w_card_style) IS NULL OR FIND_IN_SET(3,w_card_style) IS NULL AND budget_range BETWEEN 50 AND 100 GROUP BY `ser_id` HAVING `cat_id` = '11' ORDER BY `s`.`budget_range` DESC
のようなクエリを与えているNULLされているので、どのように削除するには、クエリからNULL ISまた、後にブラケットを追加する必要がある "WHERE s
。cat_id
= '11' AND" この
SELECT `c`.`city_name`, `s`.`name`, `s`.`location`, `s`.`starting_price`, `s`.`budget_range`, `s`.`cat_id`, `s`.`id`, `i`.`path`, `s`.`specification_status`, `s`.`per_unit_charge`, `s`.`w_card_style`, `s`.`w_card_style`, `s`.`budget_range` FROM `image_gallery` as `i` JOIN `specification` as `s` ON `i`.`ser_id`=`s`.`id` JOIN `cities` as `c` ON `c`.`city_id`=`s`.`location` JOIN `wcard_style` as `ws` ON `ws`.`id`=`s`.`w_card_style` WHERE `s`.`cat_id` = '11' AND (FIND_IN_SET(1,w_card_style) IS NULL OR FIND_IN_SET(2,w_card_style) IS NULL OR FIND_IN_SET(3,w_card_style) IS NULL) AND budget_range BETWEEN 50 AND 100 GROUP BY `ser_id` HAVING `cat_id` = '11' ORDER BY `s`.`budget_range` DESC`enter code here`
[\ _in \ _set見つけるにIS NULLを追加するのCodeIgniter](https://stackoverflow.com/questions/33390038/codeigniter-adding-the-is-null-in-the-の正確な複製find-in-set) – mickmackusa