API16

JDatabaseMySQLi/loadObject: Difference between revisions

From Joomla! Documentation

Sams (talk | contribs)
Added code example
m preparing for archive only
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
This global function loads the first row of a query into an object
This global function loads the first row of a query into an object


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JDatabaseMySQLi/loadObject|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JDatabaseMySQLi/loadObject}}
 
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 46: Line 44:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JDatabaseMySQLi/loadObject|Edit See Also]]<nowiki>]</nowiki>
<! removed transcluded page call, red link never existed >
</span>
{{SeeAlso:JDatabaseMySQLi/loadObject}}


===Examples===
===Examples===
Line 57: Line 53:
$results = $db->loadArrayList();
$results = $db->loadArrayList();
</source>
</source>
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=loadObject
  category=loadObject
  category=JDatabaseMySQLi
  category=JDatabaseMySQLi
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Latest revision as of 01:29, 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/mysqli.php

Importing

jimport( 'joomla.database.database.mysqli' );

Source Body

public function loadObject($className = 'stdClass')
{
        if (!($cur = $this->query())) {
                return null;
        }
        $ret = null;
        if ($object = mysqli_fetch_object($cur, $className)) {
                $ret = $object;
        }
        mysqli_free_result($cur);
        return $ret;
}


<! removed transcluded page call, red link never existed >

Examples

$db = &JFactory::getDBO();
$db->setQuery("SELECT * FROM #__categories");
$results = $db->loadArrayList();

Code Examples