limit.inc

来自「apache windows下的一款好」· INC 代码 · 共 26 行

INC
26
字号
<?php
error_reporting(E_ALL);
function pe($obj) {
    die($obj->getMessage() . "\n" . $obj->getDebugInfo());
}
$dbh->setErrorHandling(PEAR_ERROR_RETURN);
$dbh->query("DROP TABLE php_limit");
$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
$dbh->query("CREATE TABLE php_limit (a VARCHAR(20))");
$from    = 0;
$count   = 10;
$numrows = 30;

for ($i=0; $i<=$numrows+2; $i++) {
    $dbh->query("INSERT INTO php_limit VALUES('result $i')");
}
for ($i = 0; $i <= 3; $i++) {
    $from = 10 * $i;
    $res = $dbh->limitQuery("select * from php_limit", $from, $count);
    echo "======= From: $from || Number of rows to fetch: $count =======\n";
    while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
        echo $res->getRowCounter() . '.- ' . $row['a'] . "\n";
    }
}
$dbh->query("DROP TABLE php_limit");
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?