Hi!
How do I retrieve data from a table in Joomla 1.5 without using MCV?
Thank you!
Retrieve data from database
- robilro1
- Joomla! Enthusiast
- Posts: 112
- Joined: Thu Nov 22, 2007 1:10 pm
- Location: Romania
- Contact:
Retrieve data from database
Robintel BMS.
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")
- carsten888
- Joomla! Ace
- Posts: 1224
- Joined: Sat Feb 11, 2006 8:32 am
- Contact:
Re: Retrieve data from database
I don't know what you mean with MCV, but this is the code i always use:
Code: Select all
$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 my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...
- robilro1
- Joomla! Enthusiast
- Posts: 112
- Joined: Thu Nov 22, 2007 1:10 pm
- Location: Romania
- Contact:
Re: Retrieve data from database
Hi!
Thanks.
My second question is: what do these lines mean?
Thanks again.
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!")
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")
- carsten888
- Joomla! Ace
- Posts: 1224
- Joined: Sat Feb 11, 2006 8:32 am
- Contact:
Re: Retrieve data from database
er...My second question is: what do these lines mean?
make an instance of the database-object (joomla 1.5.x only)
Code: Select all
$db = JFactory::getDBO();
Code: Select all
$query = "SELECT content_id"
. " FROM #__content_frontpage"
. " WHERE content_id = $item_id"
. " LIMIT 1"
;
Code: Select all
$db->setQuery($query);
Code: Select all
$rows = $db->loadObjectList();
Code: Select all
$itemrow = $rows[0];
Code: Select all
$on_frontpage = $itemrow->content_id;
hope that helps
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...
- robilro1
- Joomla! Enthusiast
- Posts: 112
- Joined: Thu Nov 22, 2007 1:10 pm
- Location: Romania
- Contact:
Re: Retrieve data from database
That helps, thanks!
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?
Thanks!
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?
Thanks!
Robintel BMS.
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")
"Cine o cauta suficient o gaseste!" ("The one looking for it long enough, will find it!")
- carsten888
- Joomla! Ace
- Posts: 1224
- Joined: Sat Feb 11, 2006 8:32 am
- Contact:
Re: Retrieve data from database
sorry, don't know. maybe you should test that.does the DB instance...work with PostgreSQL too
http://www.pages-and-items.com my extensions:
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...
User-Private-Page, Redirect-on-Login, Admin-Help-Pages, Dynamic-Menu-Links, Admin-Menu-Manager, plugin load module in article, plugin pure css tooltip and more...