2013-07-23 80 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; 
    } 

希望它幫助;)

相關問題