Пример #1
0
 /**
  * Get list of Ads with pictures
  * @param int $cat - category ID
  * @param int $country - country ID
  * @param int $subcat - subcat ID
  * @param string $sort - sort param, default sorted by pubdate
  * @param int $first - for pagging, from which item
  * @param int $cnt - for pagging, count of returned items
  * @param int $region - region ID
  * @param int $city - city ID
  * @return array
  */
 public function GetList($cat, $params = array())
 {
     $sql = 'SELECT * FROM ' . $this->mTbAds . ' WHERE id = id';
     if ((int) $cat) {
         $sql .= ' AND id_cat = ' . (int) $cat;
     }
     if (!empty($params['search'])) {
         $search = mb_strtolower(mysql_escape_string(strip_tags($params['search'])), 'utf8');
         $sql .= ' AND LOWER(title) LIKE "%' . $search . '%"';
     }
     if (!empty($params['where'])) {
         $sql .= $where;
     }
     if (!empty($params['where']) && $params['active'] != -1) {
         $sql .= ' AND active = ' . $params['active'];
     }
     $sql .= !empty($params['sort']) ? ' ORDER BY ' . $params['sort'] : ' ORDER BY title ASC';
     $r = array();
     if (isset($params['cnt']) && isset($params['first'])) {
         $db = $this->mDb->limitQuery($sql, $params['first'], $params['cnt']);
     } else {
         $db = $this->mDb->query($sql);
     }
     include_once 'Model/Base/Cats.class.php';
     $mDict = new Model_Base_Cats($this->mDb);
     while ($row = $db->FetchRow()) {
         $row['path'] = $mDict->buildCatPath($row['id_cat']);
         $r[] = $row;
     }
     return $r;
 }