yangsai@163.com 6 months ago
parent a163b134f8
commit 79d92a2e55
  1. 1
      application/controllers/Api/Cage.php
  2. 4
      application/models/Cage.php

@ -46,6 +46,7 @@ class Api_CageController extends Ctrl_Api{
$params['uid'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; $params['uid'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$params['keyword'] = empty($this->POST['keyword'])?'':$this->POST['keyword']; $params['keyword'] = empty($this->POST['keyword'])?'':$this->POST['keyword'];
$params['page'] = empty($this->POST['page'])?1:$this->POST['page']; $params['page'] = empty($this->POST['page'])?1:$this->POST['page'];
$params['desc'] = empty($this->POST['desc'])||!isset($this->POST['desc'])?'desc':Tool_Fnc::safe_string($this->POST['desc']);
$data = $this->Cagemodel->getModelList($params); $data = $this->Cagemodel->getModelList($params);
Tool_Fnc::apiMsg('笼位获取成功', '200',$data); Tool_Fnc::apiMsg('笼位获取成功', '200',$data);
} }

@ -25,9 +25,9 @@ class CageModel extends Orm_Base{
$sql .=" and (number like '%{$params['keyword']}%' or strains like '%{$params['keyword']}%')"; $sql .=" and (number like '%{$params['keyword']}%' or strains like '%{$params['keyword']}%')";
} }
if(!empty($params['order'])){ if(!empty($params['order'])){
$sql .=" order by {$params['order']} desc"; $sql .=" order by {$params['order']} {$params['desc']}";
}else{ }else{
$sql .=" order by id desc"; $sql .=" order by id {$params['desc']}";
} }
$data['count'] = count($this->query($sql)); $data['count'] = count($this->query($sql));
$offset = ($params['page']-1)*$limmit; $offset = ($params['page']-1)*$limmit;

Loading…
Cancel
Save