2013-07-23 56 views

回答

0

尝试下面的查询和调整您的需求:

public function getMyArticles($catid){ 
     $result = null; 
     $db = JFactory::getDbo(); 
     $query = $db->getQuery(true); 
     $query->select('id, title, alias') // add other fields that might interest you 
       ->from('#__content') 
       ->where('catid='.$db->quote($catid)) 
       ->order('RAND() LIMIT 4'); // just an example for the ordering clause 
     try { 
      $db->setQuery($query); 
      $result = $db->loadObjectList(); 
     } 
     catch(RuntimeException $e){ 
      echo $e->getMessage(); 
     } 
     return $result; 
    } 

希望它帮助;)

相关问题