gpt4 book ai didi

php - Codeigniter 组合的 AND OR 条件不起作用

转载 作者:行者123 更新时间:2023-11-30 21:48:58 25 4
gpt4 key购买 nike

<分区>

代码点火器:

$this->db->select("item.*");
$this->db->from("items");
$this->db->where_not_in('item.ID', $Not);
$this->db->where_in('item_sub_category.Sub_category', $Sub_category);
$this->db->or_where_in('item_category.Category',$Category, NULL, FALSE);
$this->db->limit(4);
return $this->db->get()->result_array();

输出:

SELECT `item`.* 
FROM `item`
LEFT JOIN `item_category`
ON `item_category`.`item` = `item`.`id`
LEFT JOIN `item_sub_category`
ON `item_sub_category`.`item` = `item`.`id`
WHERE `item`.`id` NOT IN( '12' )
AND `item_sub_category`.`sub_category` IN( '65', '66', '67', '68' )
OR `item_category`.`category` IN( '35', '36' )
LIMIT 4

预期输出:

SELECT `item`.* 
FROM `item`
LEFT JOIN `item_category`
ON `item_category`.`item` = `item`.`id`
LEFT JOIN `item_sub_category`
ON `item_sub_category`.`item` = `item`.`id`
WHERE `item`.`id` NOT IN( '12' )
AND (`item_sub_category`.`sub_category` IN( '65', '66', '67', '68' )
OR `item_category`.`category` IN( '35', '36' ))
LIMIT 4

谁能告诉我如何使用事件记录实现我的预期输出?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com