Exemplo n.º 1
0
 public static function eventReply($key)
 {
     $db = Vera_Database::getInstance();
     $result = $db->select('wechat_Click', '*', array('event_key' => $key));
     if (!$result) {
         return false;
     }
     return $result[0];
 }
Exemplo n.º 2
0
 private static function getActs()
 {
     $db = Vera_Database::getInstance();
     $start = date("Y-m-d H:i:s", time() + 86400);
     //一天内
     $end = date("Y-m-d H:i:s", time() - 3600);
     //过期一小时内
     $condition = "startTime <= '{$start}'  and '{$end}' <= endTime and isPassed = 1";
     return $db->select('rollcall_Board', 'md5', $condition);
 }
Exemplo n.º 3
0
 protected static function getUserInfo()
 {
     if (empty(self::$resource)) {
         throw new Exception("Resource can not be empty", 1);
     }
     if (!($db = Vera_Database::getInstance())) {
         throw new Exception("Cannot get instance of database", 1);
     }
     $result = $db->select('vera_User', '*', array('wechat_id' => self::$resource['openid']));
     if (!$result) {
         self::$userInfo = -1;
         return NULL;
     }
     self::$userInfo = $result[0];
     return $result[0];
 }
Exemplo n.º 4
0
 protected function getYibanInfo()
 {
     if (empty(self::$resource)) {
         return false;
     }
     if (!($db = Vera_Database::getInstance())) {
         return false;
     }
     $num = $this->getStuNum();
     $result = $db->select('vera_Yiban', '*', array('xmu_num' => $num, 'fromApp' => 'mall'));
     if (!$result) {
         self::$yibanInfo = -1;
         return false;
     }
     self::$yibanInfo = $result[0];
     return $result[0];
 }
Exemplo n.º 5
0
 /**
  * @brief 查询接口
  *
  * @param $sql 查询sql
  * @param $fetchType 结果集抽取类型
  * @param $bolUseResult 是否使用MYSQLI_USE_RESULT
  *
  * @return 结果数组:成功;false:失败
  */
 public function query($sql, $fetchType = Vera_Database::FETCH_ASSOC, $bolUseResult = false)
 {
     if (!is_string($sql)) {
         Vera_Log::addWarning("Input SQL is not valid: '" . $sql . "'");
         return false;
     }
     self::$lastSql = $sql;
     $res = $this->mysql->query($sql, $bolUseResult ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT);
     $ret = false;
     // res is NULL if mysql is disconnected
     if (is_bool($res) || $res === NULL) {
         $ret = $res == true;
         if (!$ret) {
             Vera_Log::addWarning("MySQL query failed: '" . $sql . "'");
         }
     } else {
         switch ($fetchType) {
             case Vera_Database::FETCH_ASSOC:
                 $ret = array();
                 while ($row = $res->fetch_assoc()) {
                     $ret[] = $row;
                 }
                 $res->free();
                 break;
             case Vera_Database::FETCH_ROW:
                 $ret = array();
                 while ($row = $res->fetch_row()) {
                     $ret[] = $row;
                 }
                 $res->free();
                 break;
             default:
                 $ret = $res;
                 break;
         }
     }
     return $ret;
 }
Exemplo n.º 6
0
 /**
  * 取未来一段时间的任务,未推送且已审核通过
  * @param  integer $seconds 未来一段时间(秒)
  * @return  array            任务数组
  */
 public function getNowTasks($seconds = 600)
 {
     $db = Vera_Database::getInstance();
     $next = date("Y-m-d H:i:s", time() + $seconds);
     $cond = "pushTime <= '{$next}' and state = 0 and review = 1";
     //取出未来一段时间以内没有推送过的任务
     $result = $db->select('wechat_PushTask', '*', $cond);
     if (!$result) {
         return false;
     }
     return $result;
 }
Exemplo n.º 7
0
 /**
  * @param string $yb_uid 易班id
  * @param int $teacher_id 老师id
  * @return int 影响行数
  * @author nili <*****@*****.**>
  */
 public static function vote($teacher_id, $yb_uid)
 {
     $db = Vera_Database::getInstance();
     $db->insert('wap_TeacherLog', array('yb_uid' => $yb_uid, 'teacher_id' => $teacher_id, 'time' => date('Y-m-d H:i:s')));
     $where = array('id' => $teacher_id);
     $set = 'vote=vote + 1';
     $db->update('wap_Teacher', $set, $where);
 }
Exemplo n.º 8
0
 /**
  * 插入一条抽奖日志
  * @param string $yiban_uid 易班id
  * @param string $xmu_num 学号
  * @param string $award 获得网薪值
  * @return  int 影响行数
  * @author nili 
  */
 public static function insertLog($yiban_uid, $xmu_num, $award)
 {
     $db = Vera_Database::getInstance();
     return $db->insert('wechat_TmpLuck', array('xmu_num' => $xmu_num, 'yiban_uid' => $yiban_uid, 'award' => $award, 'time' => date("Y-m-d H:i:s")));
 }
Exemplo n.º 9
0
 /**
  * 根据学号获取密码
  * @param string  $xmu_num 学号
  * @return string 密码
  * @author nili
  */
 public static function getPwdByXmuNum($xmu_num)
 {
     $db = Vera_Database::getInstance();
     $res = $db->select('vera_User', 'xmu_password', array('xmu_num' => $xmu_num));
     return $res[0]['xmu_password'];
 }