Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * Tests the drivers' numCols() method
5
 *
6
 * Executed by driver/04numcols.phpt
7
 *
8
 * PHP versions 4 and 5
9
 *
10
 * LICENSE: This source file is subject to version 3.0 of the PHP license
11
 * that is available through the world-wide-web at the following URI:
12
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
13
 * the PHP License and are unable to obtain it through the web, please
14
 * send a note to license@php.net so we can mail you a copy immediately.
15
 *
16
 * @category   Database
17
 * @package    DB
18
 * @author     Daniel Convissor <danielc@php.net>
19
 * @copyright  1997-2005 The PHP Group
20
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
21
 * @version    $Id: numcols.inc,v 1.7 2005/02/03 05:49:44 danielc Exp $
22
 * @link       http://pear.php.net/package/DB
23
 */
24
 
25
/**
26
 * Local error callback handler
27
 *
28
 * Drops the phptest table, prints out an error message and kills the
29
 * process.
30
 *
31
 * @param object  $o  PEAR error object automatically passed to this method
32
 * @return void
33
 * @see PEAR::setErrorHandling()
34
 */
35
function pe($o) {
36
    global $dbh;
37
 
38
    $dbh->setErrorHandling(PEAR_ERROR_RETURN);
39
    drop_table($dbh, 'phptest');
40
 
41
    die($o->toString());
42
}
43
 
44
$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
45
 
46
 
47
$sth = $dbh->query("SELECT a FROM phptest");
48
printf("%d\n", $sth->numCols());
49
$sth = $dbh->query("SELECT a,b FROM phptest");
50
printf("%d\n", $sth->numCols());
51
$sth = $dbh->query("SELECT a,b,c FROM phptest");
52
printf("%d\n", $sth->numCols());
53
$sth = $dbh->query("SELECT * FROM phptest");
54
printf("%d\n", $sth->numCols());
55
 
56
 
57
switch ($dbh->phptype) {
58
    case 'ibase':
59
        /*
60
         * Interbase doesn't allow dropping tables that have result
61
         * sets still open.
62
         */
63
        $dbh->freeResult($sth->result);
64
        break;
65
}
66
$dbh->setErrorHandling(PEAR_ERROR_RETURN);
67
drop_table($dbh, 'phptest');