Exemple #1
0
 /**
  * retrieve categories from the database
  *
  * @param object $criteria {@link CriteriaElement} conditions to be met
  * @param bool $id_as_key use the categoryid as key for the array?
  * @return array array of {@link XoopsItem} objects
  */
 function &getObjects($criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->db->prefix('smartsection_categories');
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         if ($criteria->getSort() != '') {
             $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
         }
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     //echo "<br />" . $sql . "<br />";
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $category = new ssCategory();
         $category->assignVars($myrow);
         $category->assignOtherProperties();
         if (!$id_as_key) {
             $ret[] =& $category;
         } else {
             $ret[$myrow['categoryid']] =& $category;
         }
         unset($category);
     }
     return $ret;
 }