예제 #1
6
파일: UserLike.php 프로젝트: bmchun/sunset
 function itemLikeSum($itemID)
 {
     $re = UserLike::userlike_sum($itemID);
     $line = mysql_fetch_array($re);
     $data = array('id' => $itemID);
     $re2 = mysql_fetch_array(ItemInfo::ItemInfo_select($data, 1));
     $water = $re2['stockNum'];
     //加水收藏
     $sum = $line[0] + $water;
     return $sum;
 }
예제 #2
5
파일: like.php 프로젝트: bmchun/sunset
<?php

require_once '../../models/UserLike.php';
require_once '../../models/Response.php';
require_once '../../models/data/ItemInfo.php';
//收藏、取消收藏接口
//$islike =1  收藏  $islike=0 取消收藏
$res = new Response();
$ul = new UserLike();
if (isset($_POST['islike']) && isset($_POST['uid']) && isset($_POST['itemID'])) {
    $islike = $_POST['islike'];
    $uid = $_POST['uid'];
    $itemid = $_POST['itemID'];
    if (1 == $islike) {
        $arr = array('userid' => $uid);
        $limit = 1;
        $re = mysql_fetch_assoc($ul->userlike_select($arr, $limit));
        $like_arr_items = explode(',', $re['items']);
        if ($re) {
            if (in_array($itemid, $like_arr_items)) {
                echo $res->show(200);
                exit;
            }
            $arr = array('items' => $re['items'] . ',' . $itemid);
            $condition = '`userid`=' . $uid;
            $re = $ul->userlike_update($arr, $condition);
            if ($re) {
                echo $res->show(200);
            } else {
                echo $res->show(500);
            }
예제 #3
0
 function likeNum($uid)
 {
     $arr = array('userid' => $uid);
     $limit = 1;
     $re = new UserLike();
     $data = $re->userlike_select($arr, $limit);
     $line = mysql_fetch_array($data, MYSQL_ASSOC);
     $items = explode(',', $line['items']);
     return count(array_filter($items));
 }
예제 #4
-2
 function isFavorite($itemId, $uid)
 {
     $arr = array('userid' => $uid);
     $re = UserLike::userlike_select($arr, $limit);
     $line = mysql_fetch_array($re, MYSQL_ASSOC);
     $items = explode(',', $line['items']);
     $re = in_array($itemId, $items);
     return $re;
 }