gpt4 book ai didi

php - 如何在codeigniter中使用where子句连接两个表?

转载 作者:行者123 更新时间:2023-11-29 21:39:10 24 4
gpt4 key购买 nike

我正在开发好友请求和通知系统!当用户发送好友请求时,第二个用户收到通知!当第二个用户接受它时,通知表的 did_read 字段中更新为 1。我已经尝试过,但它显示了所有通知,包括已读(did_read = 1)。请告诉我我的代码中的问题出在哪里。谢谢

我的函数如下

public function manage_friend_req($loginuser){


$this->db->select('from_user,to_user,did_read,avatar');
$this->db->from('notifications');
$this->db->join('users','users.username = notifications.from_user');
$this->db->where(array('notifications.to_user'=>$loginuser));
$this->db->where('notifications.did_read',0);
$query = $this->db->get();
return $query->result();

} // 'did_read' field in database is an enum.

最佳答案

  1. $this->db->or_where('notifications.did_read',0);//使用或
  2. $this->db->where('notifications.did_read',0);//使用和

关于php - 如何在codeigniter中使用where子句连接两个表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34676527/

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