Reputation: 462
I'm developing a component and trying to call data from DB. I can see some different ways to implement that data call. Some components use a straightforward select + where + loadObject
to retrieve the data, and some use JTable to do that, like Lendr.
What is the recommended way to fetch data in Joomla, and is there any tutorial for JTable with J3?
Upvotes: 1
Views: 3546
Reputation: 2731
I'd say it depends on what you need. JTable usually loads a whole table row with all its columns. If that is what you need, then you can use this. In the administration section, this is often enough all you need.
In frontend however, you usually want to fetch data from different tables using joins, then you'd use your own query using the query builder. Docpage is here: http://docs.joomla.org/Accessing_the_database_using_JDatabase
Upvotes: 1
Reputation: 45124
I use below method for few reason.
http://docs.joomla.org/Accessing_the_database_using_JDatabase/3.1
rather than using JTable it has more customisation options. You can build your queries just like you want to.
Also I use JTable for basic CRUD queries. By using a mix you can get done more work by doing less.
Upvotes: 2