The Joomla! Forum ™





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Jul 17, 2008 5:18 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Nov 22, 2007 1:10 pm
Posts: 112
Location: Romania
Hi!

How do I retrieve data from a table in Joomla 1.5 without using MCV?

Thank you!

_________________
Robintel BMS.
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")


Top
 Profile  
 
PostPosted: Sun Jul 20, 2008 11:43 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Sat Feb 11, 2006 8:32 am
Posts: 1113
Location: Tilburg, Holland
I don't know what you mean with MCV, but this is the code i always use:

Code:
$db = JFactory::getDBO();

$query = "SELECT content_id"
. " FROM #__content_frontpage"
. " WHERE content_id = $item_id"
. " LIMIT 1"
;
$db->setQuery($query);
$rows = $db->loadObjectList();
$itemrow = $rows[0];
$on_frontpage = $itemrow->content_id;

_________________
http://www.pages-and-items.com
Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Frontend-User-Access, Admin-User-Access, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip


Top
 Profile  
 
PostPosted: Mon Jul 21, 2008 11:03 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Nov 22, 2007 1:10 pm
Posts: 112
Location: Romania
Hi!

Thanks.

My second question is: what do these lines mean?

Thanks again.

_________________
Robintel BMS.
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")


Top
 Profile  
 
PostPosted: Mon Jul 21, 2008 3:28 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Sat Feb 11, 2006 8:32 am
Posts: 1113
Location: Tilburg, Holland
Quote:
My second question is: what do these lines mean?

er... :geek:

make an instance of the database-object (joomla 1.5.x only)
Code:
$db = JFactory::getDBO();


make a query to select something from the database.
Code:
$query = "SELECT content_id"
. " FROM #__content_frontpage"
. " WHERE content_id = $item_id"
. " LIMIT 1"
;


execute the query
Code:
$db->setQuery($query);


get the results of the query back as a object
Code:
$rows = $db->loadObjectList();


in this bit of code I only needed the data from one row
Code:
$itemrow = $rows[0];


read value from some table's row's column
Code:
$on_frontpage = $itemrow->content_id;


:)

hope that helps

_________________
http://www.pages-and-items.com
Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Frontend-User-Access, Admin-User-Access, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip


Top
 Profile  
 
PostPosted: Tue Jul 22, 2008 9:12 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Nov 22, 2007 1:10 pm
Posts: 112
Location: Romania
:D That helps, thanks! :D

My "not so bright" question is: does the DB instance ($db = JFactory::getDBO();) work with PostgreSQL too, or this is only used to retrieve data from the Joomla MySQL database?

:pop

Thanks!

_________________
Robintel BMS.
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")


Top
 Profile  
 
PostPosted: Tue Jul 22, 2008 1:19 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Sat Feb 11, 2006 8:32 am
Posts: 1113
Location: Tilburg, Holland
Quote:
does the DB instance...work with PostgreSQL too

sorry, don't know. maybe you should test that. ;)

_________________
http://www.pages-and-items.com
Admin-Menu-Manager, Access-Manager, Redirect-on-Login, Frontend-User-Access, Admin-User-Access, Pages-and-Items, module Admin-Messages, module Logged-in-Users, plugin load module in article, plugin pure css tooltip


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 



Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group