gpt4 book ai didi

php - 进行 CodeIgniter 数据库查询

转载 作者:可可西里 更新时间:2023-10-31 23:41:52 25 4
gpt4 key购买 nike

有人可以帮我用 Codeigniter Active record 完成这个查询吗?:

我有一个包含两个值的 int 数组:

 $prices =  array( 
[0] => 23,
[1] => 98
);
how i can make something like :

return $this->db->query("select * from product where price IN (?)", array(implode(',',$prices))->result();

请帮忙。

最佳答案

试试这个(未经测试)

$query = $this->db->from('product')
->where_in('price', implode(',',$prices))
->get();

CodeIgniter Active Record docs非常好,所以你一定要仔细阅读。例如,您会注意到 select() 方法是不必要的,因为我们需要所有项目,所以假定为 *

关于php - 进行 CodeIgniter 数据库查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14676485/

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