Forums

(solved) list articles with table join

?
Guest 01 Sep, 2011
hi all,

I would like to list the articles of a specific section (with several cats) created by the logged user.

since the columns displayed should be article_title, category_title, edit link the following query should be used:
$user =& JFactory::getUser();
$query = "SELECT a.*, c.title AS category
         FROM #__content AS a
         INNER JOIN #__categories AS c ON c.id = a.catid
         WHERE a.created = '<?php echo $user->id; ?>'
         AND a.sectionid = 2 
         ORDER BY c.title, a.title ";


I have:
DBMRL 1:
Table: #__content
Model ID: Manage_Articles
Load Data / Enable Associations: yes
Associated Models: Categories
WHERE statement:
<?php $user =& JFactory::getUser(); ?>
Manage_Articles.catid = Categories.id
AND Manage_Articles.created_by = '<?php echo $user->id; ?>'
AND Manage_Articles.sectionid = '2'
ORDER BY Categories.title, Manage_Articles.title
Enable Pagination: bottom
Limit: 5

DBMRL 2:
Table: #__categories
Model ID: Categories
Fields:id,title
Load Data: yes
Enable Associations: no

using print_r2($form->data)
reveals a list of content item data with sectionid=2 with associated id /title from the categories table followed by a list of all categories in all available sections

is this what I am suppoed to get? why the list of all cats?
Max_admin 09 Sep, 2011
Hi Gabriela,

In DBMRL 2, please try to set "Load Data" to "No"

If this doesn't solve it then please show us the output of the print_r2, in code tags here.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
?
Guest 02 Oct, 2011
thanks Max! thats doing the trick🙂
This topic is locked and no more replies can be posted.