| [REVIEW] database->updateObject |
|
Last reviewed: Not reviewed database->updateObjectUpdates a database table row using data contained in an object. Returns false if the update failed; otherwise it returns the updated table row. Syntaxobject updateObject ( string $table, object &$object, string $keyname [, boolean $updateNulls ] )
ExamplesExample: In this example the function newUser is called to create a record in the Joomla users table, then the function updateUser is called to update one of its fields. // Create new row in users table and return the unique id allocated // if successful or false otherwise. function newUser( $name ) { global $database; $user = new stdClass; $user->id = NULL; $user->name = $name; if (!$database->insertObject( '#__users', $user, 'id' )) { echo $database->stderr(); return false; } return $user->id; } // Update an existing user record. function updateUser( $id, $username ) { global $database; $user = new stdClass; $user->id = $id; $user->username = $username; if (!$database->updateObject( '#__users', $user, 'id' )) { echo $database->stderr(); return false; } } $id = newUser( 'Linus Torvalds'); updateUser( $id, 'linus' ); Please report any errors on this page to the Developer Documentation Forum. |
|
| Last Updated ( Monday, 25 December 2006 ) |