/** * retrieve Partners from the database * * @param object $criteria {@link CriteriaElement} conditions to be met * @param bool $id_as_key use the partnerid as key for the array? * @return array array of {@link SmartpartnerPartner} objects */ function &getObjects($criteria = null, $id_as_key = false) { $ret = false; $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->_db->prefix($this->_dbtable); if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $whereClause = $criteria->renderWhere(); if ($whereClause != 'WHERE ()') { $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; } if (count($result) == 0) { return $ret; } while ($myrow = $this->_db->fetchArray($result)) { $partner = new SmartpartnerPartner(); $partner->assignVars($myrow); if (!$id_as_key) { $ret[] =& $partner; } else { $ret[$myrow['id']] =& $partner; } unset($partner); } return $ret; }
/** * retrieve Partners from the database * * @param object $criteria {@link CriteriaElement} conditions to be met * @param bool $id_as_key use the partnerid as key for the array? * @return array array of {@link SmartpartnerPartner} objects */ function &getObjects($criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->table; if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $whereClause = $criteria->renderWhere(); if ($whereClause != 'WHERE ()') { $sql .= ' ' . $criteria->renderWhere(); if ($criteria->getSort() != '') { $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); } } //echo "<br />" . $sql . "<br />";exit; $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } if (count($result) == 0) { return $ret; } global $smartpartner_partner_cat_link_handler; if (!isset($smartpartner_partner_cat_link_handler)) { $smartpartner_partner_cat_link_handler =& smartpartner_gethandler('partner_cat_link'); } while ($myrow = $this->db->fetchArray($result)) { $partner = new SmartpartnerPartner(); $partner->assignVars($myrow); if (!$id_as_key) { $ret[] =& $partner; } else { $ret[$myrow['id']] =& $partner; } $partner->setVar('categoryid', $smartpartner_partner_cat_link_handler->getParentIds($partner->getVar('id'))); unset($partner); } return $ret; }