Welcome Guest, Not a member yet? Register   Sign In
Active Record method chaining syntax
#1

[eluser]DrDave[/eluser]
Can someone tell me the correct syntax for chaining an active record update statement, or where I can find examples? I want to chain this just to get a handle on how chaining works:

Code:
$data = array( 'user_color' => 'blue' );
$this->db->where('user_id', $user_id);
$this->db->update('user', $data);

Thanks!
#2

[eluser]jmb727[/eluser]
[quote author="DrDave" date="1306198989"]Can someone tell me the correct syntax for chaining an active record update statement, or where I can find examples? I want to chain this just to get a handle on how chaining works:

Code:
$data = array( 'user_color' => 'blue' );
$this->db->where('user_id', $user_id);
$this->db->update('user', $data);

Thanks![/quote]

What do you mean by chaining?
Do you mean updating multiple table fields using an array with keys/values representing fields/new values?
#3

[eluser]cahva[/eluser]
You just chain it like this:
Code:
$data = array( 'user_color' => 'blue' );
$this->db->where('user_id', $user_id)->update('user', $data);
#4

[eluser]DrDave[/eluser]
Oh, that simple Smile I was trying to do it without the array and couldn't figure out where to put 'blue'. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB