public function add($name, $share, $creator) { $sql = 'INSERT INTO `group_list`(`name`, `share`, `creator`) VALUES(?, ?, ?)'; $arr = array($name, $share, $creator); if (Mysql::execute($sql, $arr)) { $gid = Mysql::lastInsertId(); $sql = 'INSERT INTO `group_member`(`gid`, `sid`) SELECT ?, `sid` FROM `student` WHERE `class` = ?'; Mysql::execute($sql, array($gid, $name)); return $gid; } else { return false; } }
public function add($uid, $type, $title, $content, $success) { //判断是否存在相同的推送 $sql = 'SELECT `id` FROM `push` WHERE `uid` = ? AND `type` = ? AND `title` = ? AND `content` = ? AND `success` = ? AND `received` = 0 LIMIT 1'; $data = Mysql::execute($sql, array($uid, $type, $title, $content, $success)); if (!empty($data)) { $id = $data[0]['id']; return $this->info($id); } //插入新推送 $sql = 'INSERT INTO `push`(`uid`, `type`, `title`, `content`, `success`, `time`) VALUES(?, ?, ?, ?, ?, CURRENT_TIMESTAMP)'; if (Mysql::execute($sql, array($uid, $type, $title, $content, $success))) { $id = Mysql::lastInsertId(); return $this->info($id); } return false; }
public function addQueue($title, $url) { //判断是否开启选课功能 if ('是' !== Config::getConfig('is_elective')) { throw new \Exception('加入队列失败,原因:管理员已关闭选课功能', Config::RETURN_ALERT); } $sql = "INSERT INTO `elective_queue` (`sid`, `title`, `url`, `time`)\n VALUES (?, ?, ?, CURRENT_TIMESTAMP)"; $sqlArr = array($this->sid, $title, $url); if (!Mysql::execute($sql, $sqlArr)) { throw new \Exception('加入队列失败,数据库异常', Config::RETURN_ALERT); } $id = Mysql::lastInsertId(); $baseUrl = Config::getConfig('local_base_url'); try { $http = new Http(array(CURLOPT_URL => $baseUrl . 'remind/electiveQueue?id=' . $id, CURLOPT_TIMEOUT => 1)); } catch (\Exception $e) { //pass } return array('title' => $title, 'result' => '', 'time' => date('Y-m-d H:i:s', time())); }