references:joomla.framework:database:jdatabase-insertobjectTable of Contents
insertObject
Inserts a new database table row using data from an object. Returns true if the insertion was successful; false otherwise. Syntaxvoid insertObject ( $table, &$object, $keyName, $verbose )
ExamplesThis 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. Example $database =& JFactory::getDBO(); $user = new stdClass; $user->id = NULL; $user->name = 'Linus Torvalds'; $user->username = 'linus'; if (!$database->insertObject( '#__users', $user, 'id' )) { echo $database->stderr(); } echo $user->id; might produce: Result 65
Discussion |


