Home > Article > Backend Development > php+oracle paging class_PHP tutorial
The following is a paging example program. It may seem complicated, but in fact, as long as you use it, you will find that "everything is so simple" :)
example.php
$conn = ociplogon( "test","123456","test123");
include_once "pager.inc.php";
?>
/**Pagination test starts*/
// {{{ Initial paging object
$pager = new pager();
/**将 select id,name,age from test where age>20 order by id desc 拆分*/
$sqlArr = array(conn => $conn, // Database connection
fields => " id,name,age ", // Main query statement
table => "test", // Table name
condition => " age>20 ", // Query condition
order => " order by id desc " // Sorting method
);
if (!$pager->listn($sqlArr,10,$page)) // Display 10 items per page
{
$pager->errno = 10;
die($pager->errmsg());
}
//}}}
// {{{ Data display
for( $i = 0; $i result); $i++)
{
$tmp = $pager->result[$i];
echo " id:".$tmp[ ID]."
";
echo " name:".$tmp[NAME]."