[ Index ] |
|
Code source de SPIP Agora 1.4 |
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 $from = 11; 50 $count = 3; 51 52 echo "======= Passing \$params || From: $from || Number of rows to fetch: $count =======\n"; 53 $res = $dbh->limitQuery('SELECT * FROM php_limit WHERE a < ?', $from, $count, array('result 99')); 54 while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { 55 echo $res->getRowCounter() . '.- ' . $row['a'] . "\n"; 56 } 57 58 59 switch ($dbh->phptype) { 60 case 'ibase': 61 /* 62 * Interbase doesn't allow dropping tables that have result 63 * sets still open. 64 */ 65 $dbh->freeResult($res->result); 66 break; 67 } 68 $dbh->setErrorHandling(PEAR_ERROR_RETURN); 69 $dbh->query('DROP TABLE php_limit'); 70 71 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |