php mssql 分頁SQL語句優化 持續影響

2022-09-29 13:03:12 字數 1521 閱讀 1854

複製** **如下:

php

/**

* @filename :page.sql.class.php

* @creattime :2009-01-06

* @descrition :此類為sql語句www.cppcns.com處理類。

* @updatetime-1 :null

* @version :jswweb1.0.0

* @author :fkedwgwy

* @dome :

$sql//sql語句

$allcount//總記錄數

$pagesize//頁面顯示記錄條數

$page//當前頁

$sqlc= new sqlpage($sql,$allcount,$pagesize,$page);

$sql=$sqlc->getsql();

優化後的語句:

select * from (select top 10 * from (select top 270 lsh,ztm,dyzrsm,dyzzfs,cbsm,cbny,ssh,fbsl,jcsl from ts_gcb where ssh like 'c%' order by lsh asc) as inner_tbl order by lsh desc) as outer_tbl order by lsh asc

*/ class sqlpage

function getpage()else

} function gettop()else

} /* function getsql()else

//$this->sql_e="select * from ( select top $this->top2 * from ( $this->sql1 ) as asystable order by $this->order desc ) as bsystable order by $this->order asc";

if (strpos($this->sql,"desc"))else

// echo $this->sql_e;

return $this->sql_e;

}*/

function getsql()

$sql = preg_replace('/^select\s/i', 'select top ' . ($this->top1) . ' ', $sql);

$sql = 'select * from (select top ' . $this->top2 . ' * from (' . $sql . ') as inner_tbl';

if ($orderby !== false)

$sql .= ') as outer_tbl';

if ($orderby !== false)

echo $sql;

return $sql;

} }

?>

本文標題: php mssql 分頁sql語句優化 持續影響

本文位址:

php mssql 分頁SQL語句優化 持續影響

經過sql優化後的分面查詢速度能夠得到大幅提高。filename page.sql.class.php creattime 2009 01 06 descrition 此類為sql語句處理類。updatetime 1 null version jswweb1.0.0 author fkedwgwy ...

PHP MSSQL分頁原始碼

連線資料庫 myserver 192.168.0.123 主機 myuser sa 使用者名稱 mypass 密碼 mydb mssql庫名 s mssql connect myserver,myuser,mypass d mssql select db mydb,s 分頁資訊 biao yongh...

Sql 分頁語句

with temptb as select row number over order by id as rowid,from pagecut select from temptb where rowid between 2 50 and 2 50 50 這是乙個資料分頁方法,從sql2005起就支...