- 注册时间
- 2012-5-30
- 最后登录
- 2014-2-14
- 阅读权限
- 10
- 积分
- 157
- 精华
- 0
- 帖子
- 50
|
本帖最后由 carboncocoa 于 2012-6-2 20:14 编辑
特别这个SQL
public function SearchEmploye($key, $index, $size, $sortField, $sortOrder){
$myconn = createDB();
$sql = "
select a.*, b.name dept_name, c.name position_name, d.name educational_name
from t_employee a
left join t_department b
on a.dept_id = b.id
left join t_position c
on a.position = c.id
left join t_educational d
on a.educational = d.id
where a.name like '%" . $key . "%'";
if(!empty($sortField)){
if ($sortOrder != "desc") $sortOrder = "asc";
$sql .= " order by " . $sortField . " " . $sortOrder;
}else{
$sql .= " order by createtime desc";
}
$result=mysql_query($sql,$myconn);
$data = array();
while($row=mysql_fetch_array($result))
{
array_push($data,$row);
}
$total = count($data);
$start = $index * $size;
$end = $start + $size;
if($start > count($data)){
$start = count($data);
};
if($end > count($data)){
$end = count($data);
};
$pagingData = array_slice($data,$start,$end);
$resultData = array("total"=>$total,"data"=>$pagingData);
return $resultData;
}
另外问下分页后的json格式是什么样的?
|
|