20
Jun
12

howto: execute SQL Query in a view (Joomla)

No, it doesn’t comply to MVC standards but yes it’s still handy:

$db = JFactory::getDBO();
$db->setQuery( ‘Your SQL query here‘ );
$res = $db->loadObject();

Use $res for further operations 

IE:

$db = JFactory::getDBO();
$db->setQuery( ‘SELECT c_category FROM #__sample_category WHERE c_id =’ . $k );
$res = $db->loadObject();
$category_name = $res->c_category ;
echo ‘<h2>’.$category_name.’</h2>’;

About these ads

1 Response to “howto: execute SQL Query in a view (Joomla)”


  1. July 17, 2012 at 16:30

    Good tutorial for me. i will try this.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: