gpt4 book ai didi

php - Codeigniter db 选择哪里作为数组

转载 作者:行者123 更新时间:2023-11-29 00:03:43 25 4
gpt4 key购买 nike

我有这段代码需要用来从数据库中获取结果,我在使用 codeigniter。这是查询的样子,

        $this->db->select('*');
$this->db->where('broadcast_id', $bid);
$query = $this->db->get('ih_noticeboard');
$result = $query->result();
if($query->num_rows() < 1){
$data = "no feed ";
}else{
$data = $result;
}

where子句中的$bid就是从这段代码中得到的,

    $this->db->select('broadcast_id');
$this->db->where('broadcast_subscribers', $id);
$query = $this->db->get('ih_broadcastors ');
if($query->num_rows() < 1){
$data = "user not subscribed to any broadcasting";
}else{
$ress = $query->result();
foreach ($ress as $row){
$bid = $row->broadcast_id;
}`

现在 select 只使用一个 $bid,如何将 $bid 用作数组?

最佳答案

这很简单。只需使用 $this->db->where_in('broadcast_id', $bid);

相反,如果 $this->db->where('broadcast_id', $bid);

https://ellislab.com/codeigniter/user-guide/database/active_record.html#select

关于php - Codeigniter db 选择哪里作为数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28499080/

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