CodeIgniter PHP $this->db->where() Multiple AND Conditions

CodeIgniter multiple AND conditions

Trying to achieve the basic PHP/MySQL call of multiple conditions with ‘AND’ ? i.e:

[code]UPDATE `MY_TABLE` SET `NAME` = ‘Frank’ WHERE `ID` =  ‘557’ AND `OWNER_ID` = ’22’;[/code]

This can be achieved in code igniter with multiple ‘$this->db->where()‘ functions preceding the ‘$this->db->update()‘ call – like this:

[code]$My_New_Data_Array = array(‘NAME’ => ‘Frank’);

$this->db->where(‘ID’, ‘557’);

$this->db->where(‘OWNER_ID’, ’22’);

$this->db->update(‘MY_TABLE’, $My_New_Data_Array);[/code]

——-
[SHORTCODE_Insert_Google_Adsence_Here]
OR, you can pass the multiple conditions to the ‘$this->db->where()‘ function in an array – like this:

[code]$My_New_Data_Array = array(‘NAME’ => ‘Frank’);

$My_Multiple_Statements_Array = array(‘ID’ => ‘ 557’, ‘OWNER_ID’ => ’22’);

$this->db->where($My_Multiple_Statements_Array);

$this->db->update(‘MY_TABLE’, $My_New_Data_Array);[/code]