JDatabaseMySQL/loadObject: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 48: | Line 48: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=loadObject | category=loadObject | ||
category=JDatabaseMySQL | category=JDatabaseMySQL | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 01:28, 25 March 2017
Description
This global function loads the first row of a query into an object.
<! removed transcluded page call, red link never existed >
Syntax
loadObject($className= 'stdClass')
| Parameter Name | Default Value | Description |
|---|---|---|
| $className | 'stdClass' | The name of the class to return (stdClass by default). |
Returns
object
Defined in
libraries/joomla/database/database/mysql.php
Importing
jimport( 'joomla.database.database.mysql' );
Source Body
public function loadObject($className = 'stdClass')
{
if (!($cur = $this->query())) {
return null;
}
$ret = null;
if ($object = mysql_fetch_object($cur, $className)) {
$ret = $object;
}
mysql_free_result($cur);
return $ret;
}
<! removed transcluded page call, red link never existed >
Examples
Code Examples