Update - adampatterson/Dingo-Framework GitHub Wiki

A Simple UPDATE

Updating rows is very much like a SELECT query:

// Select the table
$table = db('mytable');

// Query the database
$table->update(array('email'=>'[email protected]'))
      ->where('user','=','Joe')
      ->execute();

The above is the same as the following SQL:

UPDATE `mytable` SET `email`='[email protected]' WHERE `user`='Joe'

A More Complex Example

We can add multiple WHERE conditions to our query easily as well as update multiple columns:

// Select the table
$table = db('mytable');

// Query the database
$table->update(array('email'=>'[email protected]','name'=>'Joe Da Man'))
      ->where('user','=','Joe')
      ->clause('AND')
      ->where('email','=','[email protected]')
      ->execute();

UPDATE mytable SET email='[email protected]',name='Joe Da Man' WHERE user='Joe' AND email='[email protected]'

Note that the values '[email protected]' and 'Joe Da Man' (in addtion to the values 'Joe' and '[email protected]') are automatically cleaned of any SQL Injection.