private function dMyQA($request, $response, $app)
{
$pageno = $request['pageNo'] ? $request['pageNo'] : 1;
//$request['uid']='18000000000';$request['date']=0;
if (!isset($request['uid']) || empty($request['uid'])) {
return (array('code' => '-1', 'message' => '缺少uid'));
}
$jxs = $this->quanxian($request['uid'], '0');
if ($jxs['jxs_brand']) {
$jxs['jxs_brand'] = str_replace('[', '', $jxs['jxs_brand']);
$jxs['jxs_brand'] = str_replace(']', '', $jxs['jxs_brand']);
$jxs['jxs_brand'] = str_replace('"', '', $jxs['jxs_brand']);
$brand = $this->db->create_mapper('product_lib_brand')->select('id')->where('pid in (' . $jxs['jxs_brand'] . ')')->find_all_by();
$brandlist = '';
foreach ($brand as $brand1) {
if ($brandlist) {
$brandlist .= ',' . $brand1['id'];
} else {
$brandlist = $brand1['id'];
}
}
$where = " and (car_name in (" . $brandlist . ") or car_name is null or car_name='')";
} else {
$where = '';
}
//print_r($brandlist);exit;
//$obj=$this->db->create_mapper('qa')
//->where(array('ans_user_id'=>$request['uid']));
if ($request['type'] == '1') {
$sqlcount = 'SELECT count(*) as count from qa as a left join qa as b on
b.id=a.ask_id where a.ask_id<>0 and b.is_active=1 and a.ans_user_id=' . $request['uid']. ' and a.ans_from_id='.$request['jxs_id'].' GROUP BY a.ask_id';
$count = $this->db->getOne($sqlcount);
$page = $this->page($count, $pageno);
$sql = $sql = 'SELECT
b.id as qid,b.title,
b.cat,a.ans_user_name as qname,a.content as acontent,a.create_time,a.reply_num,
c.name as class FROM qa as a left join qa as b on
b.id=a.ask_id left join qa_cat as c on
c.id=
b.cat where a.ask_id<>0 and b.is_active=1 and a.ans_user_id=' . $request['uid'] . ' and a.ans_from_id='. $request['jxs_id'] .' GROUP BY a.ask_id order by a.create_time desc limit ' . $page['start'] . ',' . $page['pagesize'] ;
$row = $this->db->get_all($sql);
//print_r($sql);exit;
//$obj->where('ask_id<>0 and is_active=1');
} else {
$sqlcount = 'SELECT count(*) as count from qa left join qa_cat on
qa_cat.id=
qa.cat where qa.ask_id=0 and qa.is_active=1 and
qa.id not in (select distinct ask_id from qa where ans_user_id=' . $request['uid'] . ') and dep_role=' . $jxs['depart_id'] . $where;////qa as b ON
b.id=a.ask_id'; //where
a.id=145 or
a.id=139';
//$count=$this->db->getOne($sqlcount);
//echo $sqlcount;exit;
$page = $this->page($count, $pageno);
$sql = 'SELECT
a.id as qid,a.car_name,a.title,
a.cat,a.ans_user_name as qname,a.content as acontent,a.create_time,a.reply_num,
c.name as class FROM qa as a left join qa_cat as c on
c.id=
a.cat where ask_id=0 and is_active=1 and
a.id not in (select distinct ask_id from qa where ans_user_id=' . $request['uid'] . ') and c.dep_role=' . $jxs['depart_id'] . $where . ' order by a.create_time desc limit ' . $page['start'] . ',' . $page['pagesize'];
$row = $this->db->get_all($sql);
//print_r($sql);exit;
//$row=$this->db->query($sql);
//$obj->where('ask_id=0 and is_active=1');
}
//$count=$obj->count_by();
//$row=$obj->limit($page['pagesize'],$page['start'])->select('
a.id as qid,a.title,
a.cat,a.ans_user_name as qname,a.content as acontent,a.create_time,a.reply_num')
//->left_join('qa_cat as c','
c.id=
a.cat','
c.name as class')
//->find_all_by();
foreach ($row as $key => $val) {
$row[$key]['qname'] = $this->hidtel($val['qname']);
$row[$key]['date'] = date('Y-m-d H:i:s', $val['create_time']);
//$row[$key]['url']=$this->h5url.'ywbd/do_index&id='.$val['qid'];
if ($request['type'] == '1') {
unset($row[$key]['reply_num']);
}
}
$row = $this->clearNull($row);
return (array('code' => '1', 'pageNo' => $page['pageno'], 'pageTotal' => $page['pagetotal'], 'pageSize' => $page['pagesize'], 'message' => 'success ', data => $row));
}
这种代码怎么维护,求老司机带
系统里面全是这种代码