Pages

Thursday, July 14, 2011

SQL Query in Joomla

Hi to everyone,

In Joomla you create sql query easy way. Only you have to get DBO connection to start database connection only one time in a page.

$db = &JFactory::getDBO();
        $query = "select * from #__TABLENAME";
        $db->setQuery($query);
        $rows = $db->loadObjectList();

in which "TABLENAME" is your joomla table name and "#__" is behalf of "jos_". "jos_" is predefined value in every jomla table. $rows is an array in which all records has been fetched from database.

No comments:

Post a Comment