| API | Package | Subpackage | Class | Method | Reference | Last reviewed | Doc status |
|---|---|---|---|---|---|---|---|
Home |
Joomla.Framework |
Database |
JDatabase |
loadObject |
loadObject() |
Never | Work in Progress |
Loads an object with fields from the first row returned by the current SQL query. The method returns an object loaded with the data retrieved from the database. If the query fails, the method returns null.
object loadObject ()
Example
$database =& JFactory::getDBO(); $sql = 'SELECT name, username FROM #__users'; $database->setQuery( $sql ); $user = NULL; $user = $database->loadObject(); echo 'Name: ' . $user->name . '<br />'; echo 'Username: ' . $user->username;
might produce:
Result
Name: Administrator Username: admin