L.e.e. 发表于 2013-6-11 10:45:47

关于 $this->db->or_where();

where
        (A.idx_member_c_send = ".$this->session->userdata('pr_idx')." and
        A.idx_member_c_recv != ".$this->session->userdata('pr_idx')." and
        A.f_save_send = 1 and
        A.f_block = 0)
                or
        (A.idx_member_c_send != ".$this->session->userdata('pr_idx')." and
        A.idx_member_c_recv = ".$this->session->userdata('pr_idx')." and
        A.f_save_recv = 1 and
        A.f_block = 0)
        order by A.id_threads desc";


我想把这句 用 $this->db->where() , $this->db->or_where() 来表达~应该怎么写呢? 我试过了 没发现那里出错但是 就是 SELECT的数据是 不对的~是我写错条件了 还是 不能实现 那个效果?

去年明日 发表于 2013-6-11 14:49:43

你试下这样
$this->db->where(A.idx_member_c_send = ".$this->session->userdata('pr_idx')." and
      A.idx_member_c_recv != ".$this->session->userdata('pr_idx')." and
      A.f_save_send = 1 and
      A.f_block = 0);
$this->db->or_where(A.idx_member_c_send != ".$this->session->userdata('pr_idx')." and
      A.idx_member_c_recv = ".$this->session->userdata('pr_idx')." and
      A.f_save_recv = 1 and
      A.f_block = 0) ;
$this->db->order_by(A.id_threads ,"desc");

L.e.e. 发表于 2013-6-11 21:34:37

去年明日 发表于 2013-6-11 14:49 static/image/common/back.gif
你试下这样
$this->db->where(A.idx_member_c_send = ".$this->session->userdata('pr_idx')." and
       ...

我已经解决了,但是 还是谢谢你的回复 哈~~我用你说的方式 做的 可以!
页: [1]
查看完整版本: 关于 $this->db->or_where();