Esempio n. 1
0
 /**
  * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS
  *
  * @param object $criteria {@link icms_db_criteria_Element} conditions to be met
  * @param int   $limit      Max number of objects to fetch
  * @param int   $start      Which record to start at
  *
  * @return array
  */
 public function getList($criteria = null, $limit = 0, $start = 0, $debug = false)
 {
     $ret = array();
     if ($criteria == null) {
         $criteria = new icms_db_criteria_Compo();
     }
     if ($criteria->getSort() == '') {
         $criteria->setSort($this->getIdentifierName());
     }
     $sql = 'SELECT ' . (is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName);
     if (!empty($this->identifierName)) {
         $sql .= ', ' . $this->getIdentifierName();
     }
     $sql .= ' FROM ' . $this->table . " AS " . $this->_itemname;
     if (isset($criteria) && is_subclass_of($criteria, 'icms_db_criteria_Element')) {
         $sql .= ' ' . $criteria->renderWhere();
         if ($criteria->getSort() != '') {
             $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
         }
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     if ($debug) {
         icms_core_Debug::message($sql);
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         //identifiers should be textboxes, so sanitize them like that
         $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : icms_core_DataFilter::checkVar($myrow[$this->identifierName], 'text', 'output');
     }
     return $ret;
 }