Actions

JDatabaseMySQL/updateObject

From Joomla! Documentation

Syntax

updateObject($tableName, $object, $key, $updateNulls = true)

If you don't want to write your own SQL and bother with escaping you can use this method and JDatabaseMySQL will do it automatically for you.

Parameters

First parameter is a string with the name of table you are going to update

Second parameter supposed to be object, but you can easily convert associative array into object using typecasting.

Third parameter tell updateObject what property(array key) to use as a primary key.

Example:

 $user = (object) array(
   'id' => 1,
   'username' => 'user',
   'firstname' => 'Default',
   'lastname' => 'User',
 );
 
 $db = JFactory::getDBO();
 $db->updateObject('my_user_table', $user, 'id');

Every value is automatically quoted using Quote() method.