Actions

Difference between revisions of "JFactory/getDBO"

From Joomla! Documentation

(New page: Returns a reference to the global database object, only creating it if it doesn't already exist. The object returned will be of type JDatabase. ===Syntax=== object JDatabase getDB...)
 
(Fix red links)
Line 1: Line 1:
Returns a reference to the global database object, only creating it if it doesn't already exist.  The object returned will be of type [[JDatabase]].
+
Returns a reference to the global database object, only creating it if it doesn't already exist.  The object returned will be of type [http://api.joomla.org/Joomla-Platform/Database/JDatabase.html JDatabase].
 
===Syntax===
 
===Syntax===
object [[JDatabase]] getDBO()
+
object [http://api.joomla.org/Joomla-Platform/Database/JDatabase.html JDatabase] getDBO()
  
 
===Example===
 
===Example===
Line 15: Line 15:
 
===See also===
 
===See also===
 
* [http://api.joomla.org/Joomla-Framework/JFactory.html#getDBO JFactory->getDBO on api.joomla.org]
 
* [http://api.joomla.org/Joomla-Framework/JFactory.html#getDBO JFactory->getDBO on api.joomla.org]
* [[JDatabase]]
+
* [http://api.joomla.org/Joomla-Platform/Database/JDatabase.html JDatabase]
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JFactory]]</noinclude>
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JFactory]]</noinclude>

Revision as of 03:47, 8 July 2013

Returns a reference to the global database object, only creating it if it doesn't already exist. The object returned will be of type JDatabase.

Syntax

object JDatabase getDBO()

Example

In this example, the Joomla database prefix is retrieved.

$db =& JFactory::getDBO();
echo "Database prefix is : " . $db->getPrefix();

which should output something like this:

Database prefix is : jos_

See also