jQuery MiniUI

标题: php版的DATAGRID分页服务端代码是不是写错了? [打印本页]

作者: carboncocoa    时间: 2012-6-2 19:56:46     标题: php版的DATAGRID分页服务端代码是不是写错了?

本帖最后由 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格式是什么样的?

作者: niko    时间: 2012-6-3 09:50:53

参考这里:[url]http://miniui.com/docs/tutorial/datagrid.html[/url]




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2