"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/tests/pdo.php Source File", "datetime" => "Sat Dec 2 19:22:26 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

pdo.php

00001 <?php
00002 error_reporting(E_ALL);
00003 include('../adodb.inc.php');
00004 
00005 echo "<pre>";
00006 try {
00007         echo "New Connection\n";
00008         
00009         
00010         $dsn = 'pdo_mysql://root:@localhost/northwind?persist';
00011         
00012         if (!empty($dsn)) {
00013                 $DB =& NewADOConnection($dsn) || die("CONNECT FAILED");
00014                 $connstr = $dsn;
00015         } else {
00016         
00017                 $DB = NewADOConnection('pdo');
00018                 
00019                 echo "Connect\n";
00020                 
00021                 $u = ''; $p = '';
00022                 /*
00023                 $connstr = 'odbc:nwind';
00024                 
00025                 $connstr = 'oci:';
00026                 $u = 'scott';
00027                 $p = 'natsoft';
00028                 
00029                 
00030                 $connstr ="sqlite:d:\inetpub\adodb\sqlite.db";
00031                 */
00032                 
00033                 $connstr = "mysql:dbname=northwind";
00034                 $u = 'root';
00035                 
00036                 $connstr = "pgsql:dbname=test";
00037                 $u = 'tester';
00038                 $p = 'test';
00039                 
00040                 $DB->Connect($connstr,$u,$p) || die("CONNECT FAILED");
00041         
00042         }
00043         
00044         echo "connection string=$connstr\n Execute\n";
00045         
00046         //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
00047         $rs = $DB->Execute("select * from ADOXYZ where id<3");
00048         if  ($DB->ErrorNo()) echo "*** errno=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n";
00049         
00050         
00051         //print_r(get_class_methods($DB->_stmt));
00052         
00053         if (!$rs) die("NO RS");
00054         
00055         echo "Meta\n";
00056         for ($i=0; $i < $rs->NumCols(); $i++) {
00057                 var_dump($rs->FetchField($i));
00058                 echo "<br>";
00059         }
00060         
00061         echo "FETCH\n";
00062         $cnt = 0;
00063         while (!$rs->EOF) {
00064                 adodb_pr($rs->fields); 
00065                 $rs->MoveNext();
00066                 if ($cnt++ > 1000) break;
00067         }
00068         
00069         echo "<br>--------------------------------------------------------<br>\n\n\n";
00070         
00071         $stmt = $DB->PrepareStmt("select * from ADOXYZ");
00072         
00073         $rs = $stmt->Execute();
00074         $cols = $stmt->NumCols(); // execute required
00075         
00076         echo "COLS = $cols";
00077         for($i=1;$i<=$cols;$i++) {
00078                 $v = $stmt->_stmt->getColumnMeta($i);
00079                 var_dump($v);
00080         }
00081         
00082         echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n";
00083         while ($arr = $rs->FetchRow()) {
00084                 adodb_pr($arr);
00085         }
00086         die("DONE\n");
00087 
00088 } catch (exception $e) {
00089         echo "<pre>";
00090         echo $e;
00091         echo "</pre>";
00092 }
00093 
00094 ?>