资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

php写接口的日常

    /*
      评论列表
     */
    public function commentListW(){
        $base = new Base();
        $info = $base->getUserByToken();
        $shop_id = $info['shop_id'];
        $page = $this->data['page']?:1;
        $pagesize = $this->data['pagesize']?:C('ROLLPAGE');
        $search = $this->data['search'];
        $and = "";
        if($search){
            $and .= " and (c.c_name like '%{$search}%' or cu.customer_name like '%{$search}%')";
        }
        $sql0 = "select count(c.c_id) as itemcount from `comment` as c left join `customer` as cu on c.customer_id=cu.customer_id where c.shop_id='{$shop_id}' and c.com_status='0'{$and}";
        $itemcount = M()->query($sql0)[0]['itemcount'];
        $pagecount = ceil($itemcount/$pagesize);
        $limit = ($page-1)*$pagesize;
        $offset = " limit {$limit},{$pagesize}";
        $sql1 = "select c.c_id,c.c_name,c.c_pic,c.c_type,cu.customer_name,cu.headimgurl,c.com_content,c.com_time,c.reply_time,c.thumb_num,c.pic_num,c.com_reply,c.is_reply,c.com_status,c.com_status from `comment` as c left join `customer` as cu on c.customer_id=cu.customer_id where c.shop_id='{$shop_id}' and c.com_status='0'{$and} order by c.com_time desc {$offset}";
        $data = M()->query($sql1);
        $ret = array();
        $ret['data'] = $data;
        $ret['page'] = array(
                'pagecount'=>(int)$pagecount,
                'itemcount'=>(int)$itemcount,
            );
        return $ret;
    }
    /*
     点赞/取消点赞
     */
    public function doThumb(){
            $art_id = $this->data['art_id'];
            $customer_id = $this->data['customer_id'];
            $brand_id = $this->data['brand_id'];
            $time = time();
            $data = $this->getThumb();
            if($data){
                $thumb_id = $data['thumb_id'];
                $thumb_status = $data['thumb_status'];
                if($thumb_status==0){
                    $sql = "update `brand_article_thumb` set thumb_status='1' where thumb_id='{$thumb_id}'";
                }else{
                    $sql = "update `brand_article_thumb` set thumb_status='0' where thumb_id='{$thumb_id}'";
                }
            }else{
                $sql = "insert into `brand_article_thumb` (art_id,customer_id,thumb_time,brand_id) values ('{$art_id}','{$customer_id}','{$time}','{$brand_id}')";
            }
            $ret = M()->execute($sql);
            if($ret<0){
                return false;
            }else{
                return true;
            }
    }

分享标题:php写接口的日常
路径分享:http://cdkjz.cn/article/ihhcpd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220