分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

PHP写接口的日常

发布时间:2023-09-06 01:46责任编辑:白小东关键词:PHP
public function commentList(){ ???$info = $this->getUserByToken(); ???$shop_id = $info[‘shop_id‘]; ???$page = I(‘post.page‘)?:1; ???$pagesize = I(‘post.pagesize‘)?:C(‘ROLLPAGE‘); ???$c_type = I(‘post.c_type‘); ???$serach = I(‘post.serach‘); ???$and = ""; ???if($c_type == 1){ ?# ?商品 ???????if($c_type != 0){ ???????????$and .= " and co.c_type=‘{$c_type}‘"; ???????} ???????if($search){ ???????????$and .= " and (c.c_name like ‘%{$search}%‘)"; ???????} ???}else{ ???????$sql0 = "select count(s.s_id) as itemcount from `erp_commod_comment` as co left join `erp_shopping_service` as s on co.c_id=s.s_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and}"; ???} ???if($c_type == 1){ ?# ?商品 ???????$sql0 = "select count(c.c_id) as itemcount from `erp_commod_comment` as co left join `erp_commod` as c on co.c_id=c.c_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and}"; ???}else{ ???????$sql0 = "select count(s.s_id) as itemcount from `erp_commod_comment` as co left join `erp_shopping_service` as s on co.c_id=s.s_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and}"; ???} ???$itemcount = M()->query($sql0)[0][‘itemcount‘]; ???$pagecount = ceil($itemcount/$pagesize); ???$limit = ($page-1)*$pagesize; ???$offset = " limit {$limit},{$pagesize}"; ???if($c_type == 1){ ?# ?商品 ???????$sql1 = "select c.c_id,c.c_pic,c.c_name,cu.customer_id,cu.customer_name,cu.customer_type,cu.headimgurl,co.com_id,co.com_content,co.com_time,co.com_score,co.thumb_num,co.com_is_return,co.com_status from `erp_commod_comment` as co left join `erp_commod` as c on co.c_id=c.c_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and} order by co.com_status asc,co.com_time desc{$offset}"; ???}else{ ?# ?服务 ???????$sql1 = "select s.s_id,s.s_pic,s.s_name,cu.customer_id,cu.customer_name,cu.customer_type,cu.headimgurl,co.com_id,co.com_content,co.com_time,co.com_score,co.thumb_num,co.com_is_return,co.com_status from `erp_commod_comment` as co left join `erp_shopping_service` as s on co.c_id=s.s_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and} order by co.com_status asc,co.com_time desc{$offset}"; ???} ???$sql1 = ""; ???$data = M()->query($sql1); ???foreach ($data as $key => $value) { ???????$data[$key][‘shop_id‘] = M(‘commod‘,‘erp_‘)->where([‘c_id‘=>$value[‘c_id‘]])->getField(‘shop_id‘); ???} ???$ret = array(); ???$ret[‘data‘] = $data; ???$ret[‘page‘] = array( ???????????‘pagecount‘=>(int)$pagecount, ???????????‘itemcount‘=>(int)$itemcount, ???????); ???$this->ret(1,‘‘,$ret);}

PHP写接口的日常

原文地址:http://blog.51cto.com/12173069/2089125

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved