[PHP] codeigniter where

$this->CI->db->where('groupid',1);
$this->CI->db->where('group
id',2);
$this->CI->db->where('group_id',3);

select * from table where groupid = 1 and groupid = 2 and group_id = 3

....

kakšen je ukaz, da namesto and uporabim OR??

torej:

select * from table where (groupid = 1 or groupid = 2 or group_id = 3)

8 odgovorov

or_where

http://codeigniter.com/userguide/database/activerecord.html

$this->db->where('name !=', $name);
$this->db->or_where('id >', $id);

// Produces: WHERE name != 'Joe' OR id > 50

ne, zadeva ne pali... sem probal.

$this->CI->db->where('groupid',1);
$this->CI->db->or
where('groupid',2);
$this->CI->db->or
where('group_id',3);

to ne gre? javi kakšno napako ali izpiše query?

ne, zgenerira napačen query. rešitev je edino...

$this->CI->db->where("(groupid='1' or groupid='2' or group_id='3')");

A lahko daš kodo, kako si probal...

slimdeluxe poglulal sem in poiskal en podoben primer.

or_where je nesporno to kar si iskal, zanimalo me je, kaj za eno kodo si napisal, da ti ni delalo prav.

$ids = array(1,2,3);
$this->CI->db->wherein('groupid', $ids);

2