1个回答
展开全部
oracle官方自己的例子
原文http://www.oracle.com/technology/global/cn/pub/articles/oracle_php_cookbook/fuecks_paged.html
1function & paged_result(& $conn, $select, $start_row, $rows_per_page) {
2
3$sql = "SELECT
4 *
5FROM
6 (
7SELECT
8r.*, ROWNUM as row_number
9FROM
10( $select ) r
11WHERE
12ROWNUM <= :end_row
13 )
14WHERE :start_row <= row_number";
15
16$stmt = oci_parse($conn,$sql);
17
18oci_bind_by_name($stmt, ':start_row', $start_row);
19
20// Calculate the number of the last row in the page
21$end_row = $start_row + $rows_per_page - 1;
22oci_bind_by_name($stmt, ':end_row', $end_row);
23
24oci_execute($stmt);
25
26// Prefetch the number of rows per page
27oci_set_prefetch($stmt, $rows_per_page);
28
29return $stmt;
30
31}
应用这个方法,写出的临时使用的php语句类似于这样:
$select = "SELECT * FROM {$_DATABASE_TABLE_PREFIX_}toperate_log $where $order_by";
$sql = "SELECT * FROM ( SELECT r.*, ROWNUM as row_number FROM ( $select ) r WHERE ROWNUM <= ".($start + $limit)." ) WHERE $start <= row_number";
原文http://www.oracle.com/technology/global/cn/pub/articles/oracle_php_cookbook/fuecks_paged.html
1function & paged_result(& $conn, $select, $start_row, $rows_per_page) {
2
3$sql = "SELECT
4 *
5FROM
6 (
7SELECT
8r.*, ROWNUM as row_number
9FROM
10( $select ) r
11WHERE
12ROWNUM <= :end_row
13 )
14WHERE :start_row <= row_number";
15
16$stmt = oci_parse($conn,$sql);
17
18oci_bind_by_name($stmt, ':start_row', $start_row);
19
20// Calculate the number of the last row in the page
21$end_row = $start_row + $rows_per_page - 1;
22oci_bind_by_name($stmt, ':end_row', $end_row);
23
24oci_execute($stmt);
25
26// Prefetch the number of rows per page
27oci_set_prefetch($stmt, $rows_per_page);
28
29return $stmt;
30
31}
应用这个方法,写出的临时使用的php语句类似于这样:
$select = "SELECT * FROM {$_DATABASE_TABLE_PREFIX_}toperate_log $where $order_by";
$sql = "SELECT * FROM ( SELECT r.*, ROWNUM as row_number FROM ( $select ) r WHERE ROWNUM <= ".($start + $limit)." ) WHERE $start <= row_number";
参考资料: http://www.wei.org.ua/
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询