function search($svalue, $price, $level, $attr = "自主") { $db = MyPDO::getInstance('localhost', 'afei', '8823533', 'cars_db', 'utf8'); $prices = explode("-", $price); $price = $prices[0]; $priceb = isset($prices[1]) ? $prices[1] : "暂无"; $query = 'SELECT DISTINCT `name`,englishName,price,priceb,sourceId FROM(SELECT DISTINCT a.`name`, a.englishName,a.price,a.priceb,a.sourceId FROM `mediumgaugecarportfolio` a ,`mediumgaugecar` b WHERE a.sourceId=b.seriesId AND a.`name` LIKE \'%' . $svalue . '%\' AND b.valueName="级别" AND b.`value` LIKE \'%' . $level . 'SUV\' AND a.price BETWEEN ' . $price . ' AND ' . $priceb . ' UNION ALL SELECT DISTINCT a.`name`, a.englishName,a.price,a.priceb,a.sourceId FROM `mediumgaugecarportfolio` a ,`mediumgaugecar` b WHERE a.sourceId=b.seriesId AND a.`name` LIKE \'%' . $svalue . '%\' AND b.valueName="级别" AND b.`value` LIKE \'%' . $level . 'SUV\' AND a.priceb BETWEEN ' . $price . ' AND ' . $priceb . ')t ORDER BY price ASC'; $rs = $db->query($query); $db->destruct(); return $rs; }
/** * Save current Model * @param type $params */ public function save($params = null) { $instance = MyPDO::getInstance(); if (is_null($params)) { $params = $this->_data; } if (isset($params['id'])) { $id = $params['id']; unset($params['id']); $instance->updateTable($this->getTable(), $id, $params); } else { $instance->insert_table($this->getTable(), $params); } }
/** * Search users by part of fio * @param type $term * @return type */ public static function findAll($term) { $sql = 'select * from `users` where fio like "%' . $term . '%"'; $instance = MyPDO::getInstance(); return $instance->query($sql); }
public function get($id) { // On admet que MyPDO étend PDO et qu'il implémente un singleton. $q = MyPDO::getInstance()->query('SELECT id, auteur, titre, contenu FROM news WHERE id = ' . (int) $id); return $q->fetch(PDO::FETCH_ASSOC); }
/** * Delete dept * @param type $id */ public static function delete($id = null) { $instance = MyPDO::getInstance(); $instance->delete('depts', $id); }