到目前为止,我还在mysql和php中使用jqgrid。我的代码适合于jqGrid演示站点中给出的示例。
javascript部分提供的数据如下:
最后一个查询返回4行。
这是与Postgresql相同的代码。对于相同的数据,这段代码什么也不返回!
$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
if (!$sidx) $sidx =1; // connect to the database
$connection = pg_connect($con);
pg_query($connection,"set names 'utf8'");
$query = "SELECT COUNT(*) AS count FROM preference WHERE (id_membre ='$idm')";
$result = pg_query($connection,$query);
$row = pg_fetch_array($result);
$count = $row['count'];
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
}
else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
if ($start<0) $start = 0;
$query = "select * from preference where (id_membre ='$idm') order by $sidx $sord LIMIT $start OFFSET $limit";
$result = pg_query($connection,$query); 有什么想法吗?我认为极限0,8变成极限0偏移8
发布于 2013-05-04 01:16:36
mysql中的限制为0,8,这意味着postgres中的限制8偏移量为0。
$query = "select * from preference where (id_membre ='$idm')
order by $sidx $sord LIMIT $limit OFFSET $start";https://stackoverflow.com/questions/16368336
复制相似问题