public function search($key, $page = 1) { $key = "%{$key}%"; $sql = "SELECT `a`.`id`, `a`.`course`, `a`.`credit`, `a`.`total`,\n `a`.`remain`, `a`.`teacher`, `a`.`time`, `a`.`place`, `a`.`url`,\n IF(`b`.`college` IS NULL, '1' , '0.5') opacity,\n IF(`c`.`rate` IS NULL, -1 , `c`.`rate`) rate\n FROM `elective_list` `a`\n LEFT JOIN `student` `b` ON `a`.`college` = `b`.`college` AND `b`.`sid` = ?\n LEFT JOIN `failRate` `c` ON `a`.`course` = `c`.`course` AND `a`.`school` = `c`.`name`\n WHERE (`a`.`course` LIKE ? OR `a`.`teacher` LIKE ? OR `a`.`time` LIKE ? OR `a`.`place` LIKE ?)\n AND `a`.`school` = ? AND `a`.`term` = ? ORDER BY `c`.`rate` ASC"; $sqlArr = array($this->sid, $key, $key, $key, $key, $this->school, $this->term); return Mysql::paging($sql, $sqlArr, $page, 20); }
public function push() { $type = \Hnust\input('type'); $key = \Hnust\input('key'); $id = \Hnust\input('id'); $uid = \Hnust\input('uid'); $mode = \Hnust\input('mode'); $title = \Hnust\input('title'); $content = \Hnust\input('content'); $success = \Hnust\input('success'); //初始化推送对象 $push = new \Hnust\Analyse\Push(); //添加推送 if ('add' === $type) { $data = $push->add($uid, $mode, $title, $content, $success); $push->socket($data); $this->msg = '系统提示'; $this->data = '添加推送成功'; //重置推送 } elseif ('reset' === $type) { $data = $push->reset($id); if ('0' == $data['received']) { $push->socket($data); } $this->code = Config::RETURN_NORMAL; //删除推送 } elseif ('delete' === $type) { $push->delete($id); $this->code = Config::RETURN_NORMAL; //获取推送列表 } else { $sql = "SELECT `p`.`id`, `p`.`uid`, `s`.`name`, `p`.`type`, `p`.`title`, `p`.`content`,\n `p`.`success`, `p`.`received`, `p`.`time`, `p`.`upTime` FROM `push` `p`\n LEFT JOIN `student` `s` ON `s`.`sid` = `p`.`uid`\n WHERE CONCAT_WS(',', `p`.`uid`, `s`.`name`, `p`.`title`, `p`.`content`, `p`.`success`) LIKE ?\n ORDER BY `p`.`id` DESC"; $result = Mysql::paging($sql, array("%{$key}%"), $this->page); $this->data = $result['data']; $this->info = array_merge($result['info'], array('type' => $type, 'key' => $key)); } }