home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / limit.inc < prev    next >
Encoding:
Text File  |  2004-03-24  |  1.4 KB  |  61 lines

  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. /**
  5.  * Local error callback handler.
  6.  *
  7.  * Drops the phptest table, prints out an error message and kills the
  8.  * process.
  9.  *
  10.  * @param object  $o  PEAR error object automatically passed to this method
  11.  * @return void
  12.  * @see PEAR::setErrorHandling()
  13.  */
  14. function pe($o) {
  15.     global $dbh;
  16.  
  17.     $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  18.     $dbh->query('DROP TABLE php_limit');
  19.  
  20.     die($o->toString());
  21. }
  22.  
  23.  
  24. $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  25. $dbh->query('DROP TABLE php_limit');
  26.  
  27. $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
  28.  
  29. $dbh->query('CREATE TABLE php_limit (a CHAR(20))');
  30.  
  31.  
  32. $from    = 0;
  33. $count   = 10;
  34. $numrows = 30;
  35.  
  36. for ($i=0; $i<=$numrows+2; $i++) {
  37.     $dbh->query("INSERT INTO php_limit VALUES('result $i')");
  38. }
  39. for ($i = 0; $i <= 3; $i++) {
  40.     $from = 10 * $i;
  41.     $res = $dbh->limitQuery("select * from php_limit", $from, $count);
  42.     echo "======= From: $from || Number of rows to fetch: $count =======\n";
  43.     while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
  44.         echo $res->getRowCounter() . '.- ' . $row['a'] . "\n";
  45.     }
  46. }
  47.  
  48.  
  49. switch ($dbh->phptype) {
  50.     case 'ibase':
  51.         /*
  52.          * Interbase doesn't allow dropping tables that have result
  53.          * sets still open.
  54.          */
  55.         $dbh->freeResult($res->result);
  56.         break;
  57. }
  58. $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  59. $dbh->query('DROP TABLE php_limit');
  60.  
  61. ?>