--php5.2
--sqlserver2005
php读取sqlserver多条数据时,有时因为数据太多,需要进行分页查询。
例如,按价格的顺序,读取同一类型的产品的第30到第48条记录
$startNum = 30; $endNum = 48;
$type = ‘洗发水‘;
如果php页面的编码是UTF-8,sqlserver是GBK的话,
要将$type进行转码,
$type = iconv(‘UTF-8‘,‘GBK‘,$type);
接下来分页查询(数据表table1,构建临时表a),贴上代码,备忘:
$result= mssql_query("select * from
(select row_number() over(order by price) row_num, * from dbo.table1 where type = ‘$type‘)a where a.row_num between $startNum and $endNum ",$conn);
^_^完~~