jQuery MiniUI

 找回密码
 立即注册
查看: 3897|回复: 1
打印 上一主题 下一主题

php版的DATAGRID分页服务端代码是不是写错了? [复制链接]

Rank: 2

跳转到指定楼层
楼主
发表于 2012-6-2 19:56:46 |只看该作者 |倒序浏览
本帖最后由 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格式是什么样的?

Rank: 9Rank: 9Rank: 9

沙发
发表于 2012-6-3 09:50:53 |只看该作者

Archiver|普加软件

GMT+8, 2024-11-25 22:57 , Processed in 1.045515 second(s), 9 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部