[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Pear/tests/ -> numcols.inc (source)

   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  ?>


Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7