如何使用joomla 2.5在joomla模型类中编写以下查询

时间:2013-06-25 05:52:29

标签: joomla2.5

  

g5ch3_empstatus_objects选择es。*作为es内部联接(选择   statuscreator,statuscreatorid,max(created)as maxcreated,ustatus from   g5ch3_empstatus_objects其中statuscreator ='user-> name'group by   在es.statuscreator上的statuscreators = s.statuscreator和   es.created = s.maxcreated

如何使用joomla2.5

在Joomla模型类中编写此查询

我试过这种方式,但我得到空结果集:

$query = $db->getQuery(true);    
$subquery = $db->getQuery(true);
$subquery->select('max(created) as maxcreated')
-> from ('#_empstatus_objects');
$query->select(
        'es.id as id,' .
        'es.statuscreator,' .
        'es.statuscreatorid,' .
        'es.created,' .
        'es.ustatus'
);
$query->from ('#__empstatus_objects as es'.$subquery.$where)
-> group('statuscreator');

$superadmin = $this->access_superuser($user->id);
if(!$superadmin){
    $query->where ('statuscreatorid='.$user->id);    
}

1 个答案:

答案 0 :(得分:0)

转到http://docs.joomla.org/Accessing_the_database_using_JDatabase/2.5并查看“从多个表中选择记录”部分。