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

  1. <?php
  2.  
  3. /**
  4.  * Local error callback handler.
  5.  *
  6.  * Drops the phptest table, prints out an error message and kills the
  7.  * process.
  8.  *
  9.  * @param object  $o  PEAR error object automatically passed to this method
  10.  * @return void
  11.  * @see PEAR::setErrorHandling()
  12.  */
  13. function pe($o) {
  14.     global $dbh;
  15.  
  16.     $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  17.     $dbh->query('DROP TABLE phptest');
  18.  
  19.     die($o->toString());
  20. }
  21.  
  22. $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
  23.  
  24.  
  25. $sth = $dbh->query("SELECT a FROM phptest");
  26. printf("%d\n", $sth->numCols());
  27. $sth = $dbh->query("SELECT a,b FROM phptest");
  28. printf("%d\n", $sth->numCols());
  29. $sth = $dbh->query("SELECT a,b,c FROM phptest");
  30. printf("%d\n", $sth->numCols());
  31. $sth = $dbh->query("SELECT * FROM phptest");
  32. printf("%d\n", $sth->numCols());
  33.  
  34.  
  35. switch ($dbh->phptype) {
  36.     case 'ibase':
  37.         /*
  38.          * Interbase doesn't allow dropping tables that have result
  39.          * sets still open.
  40.          */
  41.         $dbh->freeResult($sth->result);
  42.         break;
  43. }
  44. $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  45. $dbh->query('DROP TABLE phptest');
  46.  
  47. ?>
  48.