| [REVIEW] database->insertObject |
|
Last reviewed: Not reviewed database->insertObjectInserts a new database table row using data from an object. Returns true if the insertion was successful; false otherwise. Syntaxboolean insertObject ( string $table, object &$object [, string $keyname [, boolean $verbose ]] )
ExamplesExample: This example inserts a new row in the Joomla users table. Notice that the 'id' field is set to null before calling insertObject and will be updated with the unique id number allocated by the database. // Create new row in users table and return the unique id allocated // if successful or false otherwise. function newUser( $name, $username) { global $database; $user = new stdClass; $user->id = NULL; $user->name = $name; $user->username = $username; if (!$database->insertObject( '#__users', $user, 'id' )) { echo $database->stderr(); return false; } return $user->id; } echo newUser( 'Linus Torvalds', 'linus' ); Please report any errors on this page to the Developer Documentation Forum. |
|
| Last Updated ( Sunday, 24 December 2006 ) |