How to write a query in CodeIgniter Active Record?

There is no way to achieve this properly using CodeIgniter Active Record.

There is no way to achieve this properly using CodeIgniter Active Record. The only way that's not too ugly is using a custom string with the where() function like this: $this->db->select( 'fruits. *' ); $this->db->from( 'fruits' ); $where = "fruits.

Color = 'red' AND ( fruits. Size = 'medium' OR fruits. Name = 'kiwi' OR fruits.

Length = 7 );"; $this->db->where( $where ); IMPORTANT: note that using a custom string, your variable WILL NOT be escaped, thus, you need to use $this->db->escape() $this->db->select( 'fruits. *' ); $this->db->from( 'fruits' ); $color = 'red'; $size = 'medium'; $name = 'kiwi'; $length = 7; $where = "fruits. Color = '".

$this->db->escape($color). "' AND ( fruits. Size = '".

$this->db->escape($size). "' OR fruits. Name = '".

$this->db->escape($name). "' OR fruits. Length = '".

$this->db->escape($length). "');"; $this->db->where( $where ); Edit: I got confused on the good query, I corrected it :).

Yeah, this is what I figured. Unfortunately my actual query has a bunch of or_where_in rather than just or_where.... so if I build a custom where string I might as well just write the whole query in raw SQL at that point :/ Thanks for the input. – Anon Jun 21 '10 at 22:38 This was one the drawback of CodeIgniter, especially now that I use Yii which is pure OOP, I notice it even more.

Otherwise a solution would be to create your own function to handle this, or to override the db class. – Weboide Jun 21 '10 at 22:49.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions