Documentation TYPO3 par Ameos

test-php5.php

00001 <?php
00002 /*
00003   V4.81 3 May 2006  (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
00004   Released under both BSD license and Lesser GPL library license. 
00005   Whenever there is any discrepancy between the two licenses, 
00006   the BSD license will take precedence.
00007   Set tabs to 8.
00008  */
00009 
00010 
00011 error_reporting(E_ALL);
00012 
00013 $path = dirname(__FILE__);
00014 
00015 include("$path/../adodb-exceptions.inc.php");
00016 include("$path/../adodb.inc.php");      
00017 
00018 echo "<h3>PHP ".PHP_VERSION."</h3>\n";
00019 try {
00020 
00021 $dbt = 'mysql';
00022 
00023 try {
00024 switch($dbt) {
00025 case 'oci8po':
00026         $db = NewADOConnection("oci8po");
00027         
00028         $db->Connect('','scott','natsoft');
00029         break;
00030 default:
00031 case 'mysql':
00032         $db = NewADOConnection("mysql");
00033         $db->Connect('localhost','root','','northwind');
00034         break;
00035         
00036 case 'mysqli':
00037         $db = NewADOConnection("mysqli://root:@localhost/northwind");
00038         //$db->Connect('localhost','root','','test');
00039         break;
00040 }
00041 } catch (exception $e){
00042         echo "Connect Failed";
00043         adodb_pr($e);
00044         die();
00045 }
00046 
00047 $db->debug=1;
00048 
00049 $cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));
00050 $stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");
00051 if (!$stmt) echo $db->ErrorMsg(),"\n";
00052 $rs = $db->Execute($stmt,array(10,20));
00053 
00054 echo  "<hr /> Foreach Iterator Test (rand=".rand().")<hr />";
00055 $i = 0;
00056 foreach($rs as $v) {
00057         $i += 1;
00058         echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true);
00059         if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);}
00060         else echo "passed<br>";
00061         flush();
00062 }
00063 
00064 
00065 if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
00066 else echo "Count $i is correct<br>";
00067 
00068 $rs = $db->Execute("select bad from badder");
00069 
00070 } catch (exception $e) {
00071         adodb_pr($e);
00072         echo "<h3>adodb_backtrace:</h3>\n";
00073         $e = adodb_backtrace($e->gettrace());
00074 }
00075 
00076 $rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
00077 echo "Result=\n",$rs,"</p>";
00078 
00079 echo "<h3>Active Record</h3>";
00080 try {
00081         include_once("../adodb-active-record.inc.php");
00082         class City extends ADOdb_Active_Record{};
00083         $a = new City();
00084 
00085 } catch(exception $e){
00086         echo $e->getMessage();
00087 }
00088 
00089 try {
00090         
00091         ADOdb_Active_Record::SetDatabaseAdapter($db);
00092         $a = new City();
00093         
00094         echo "<p>Successfully created City()<br>";
00095         var_dump($a->GetPrimaryKeys());
00096         $a->city = 'Kuala Lumpur';
00097         $a->Save();
00098         $a->Update();
00099         $a->SetPrimaryKeys(array('city'));      
00100         $a->country = "M'sia";
00101         $a->save();
00102         $a->Delete();
00103 } catch(exception $e){
00104         echo $e->getMessage();
00105 }
00106 
00107 include_once("test-active-record.php");
00108 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6