示例#1
0
文件: user.php 项目: 117n-n711/pjmgmt
 function getUserById($uid, $hash, $userId)
 {
     if (!($uid > 0)) {
         return -1;
     }
     if (!($userId > 0)) {
         return -1;
     }
     if (!checkCookies($uid, $hash)) {
         return -1;
     }
     $colsArray = array("users" => array(1, 2, 4, 5, 6, 7, 8));
     $colStr = getSqlColumns($colsArray);
     $query = "SELECT {$colStr} FROM `users` WHERE `uid`={$userId};";
     $data = array();
     if ($result = mysql_query($query)) {
         while ($res = mysql_fetch_array($result)) {
             $data["user"] = getSqlData($colsArray, $res);
         }
     }
     $colsArray = array("item" => array(1, 3, 4, 11));
     $colStr = getSqlColumns($colsArray);
     $query = "SELECT {$colStr} FROM `item` WHERE `item`.`uid`={$userId};";
     if ($result = mysql_query($query)) {
         $inndata = array();
         while ($res = mysql_fetch_array($result)) {
             array_push($inndata, getSqlData($colsArray, $res));
         }
         $data["items"] = $inndata;
     }
     return $data;
 }
示例#2
0
 function getNotification($uid, $hash)
 {
     if (!($uid > 0)) {
         return -1;
     }
     if (!checkCookies($uid, $hash)) {
         return false;
     }
     $colsArray = array("borrow" => array(1, 2, 3, 4, 5, 6, 7), "item" => array(1, 3, 4));
     $colStr = getSqlColumns($colsArray);
     $query = "SELECT {$colStr} FROM `item`, `borrow` WHERE `borrow`.`iid`=`item`.`iid` AND `item`.`uid`={$uid} AND `item`.`status`=1;";
     $data = array();
     if ($result = mysql_query($query)) {
         while ($res = mysql_fetch_array($result)) {
             $data[$res["bid"]] = getSqlData($colsArray, $res);
         }
     }
     return $data;
 }
示例#3
0
 function getReply($iid)
 {
     //
     $colsArray = array("replycomment" => array(1, 3, 4, 5, 6));
     $colStr = getSqlColumns($colsArray);
     $query = "SELECT {$colStr} FROM `replycomment` WHERE `iid`={$iid};";
     if ($result = mysql_query($query)) {
         $comments = array();
         while ($res = mysql_fetch_array($result)) {
             if (!isset($comments[$res["cid"]])) {
                 $comments[$res["cid"]] = array();
             }
             $comments[$res["cid"]][$res["rcid"]] = getSqlData($colsArray, $res);
         }
         return $comments;
     }
 }
示例#4
0
 function getUsersBySearch($q)
 {
     $q = mysql_real_escape_string($q);
     $colsArray = array("users" => array(1, 2, 4, 5, 6));
     $colStr = getSqlColumns($colsArray);
     $query = "SELECT {$colStr} FROM `users` WHERE (`users`.`email` LIKE '%{$q}%') OR (`users`.`uname` LIKE '%{$q}%') OR (`users`.`fname` LIKE '%{$q}%') OR (`users`.`contact` LIKE '%{$q}%');";
     $items = array();
     if ($result = mysql_query($query)) {
         while ($res = mysql_fetch_assoc($result)) {
             $item = getSqlData($colsArray, $res);
             $items[] = $item;
         }
     }
     return $items;
 }