Changeset 34 for trunk/phpgwapi/inc/adodb/tests/test-php5.php
- Timestamp:
- 06/29/07 15:17:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/adodb/tests/test-php5.php
r2 r34 1 1 <?php 2 2 /* 3 V4. 51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.3 V4.81 3 May 2006 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 4 4 Released under both BSD license and Lesser GPL library license. 5 5 Whenever there is any discrepancy between the two licenses, … … 19 19 try { 20 20 21 $dbt = ' oci8po';21 $dbt = 'mysql'; 22 22 23 try { 23 24 switch($dbt) { 24 25 case 'oci8po': 25 26 $db = NewADOConnection("oci8po"); 27 26 28 $db->Connect('','scott','natsoft'); 27 29 break; … … 29 31 case 'mysql': 30 32 $db = NewADOConnection("mysql"); 31 $db->Connect('localhost','root','',' test');33 $db->Connect('localhost','root','','northwind'); 32 34 break; 33 35 34 36 case 'mysqli': 35 $db = NewADOConnection("mysqli://root:@localhost/ test");37 $db = NewADOConnection("mysqli://root:@localhost/northwind"); 36 38 //$db->Connect('localhost','root','','test'); 37 39 break; 40 } 41 } catch (exception $e){ 42 echo "Connect Failed"; 43 adodb_pr($e); 44 die(); 38 45 } 39 46 … … 45 52 $rs = $db->Execute($stmt,array(10,20)); 46 53 54 echo "<hr /> Foreach Iterator Test (rand=".rand().")<hr />"; 47 55 $i = 0; 48 foreach($rs as 56 foreach($rs as $v) { 49 57 $i += 1; 50 echo "rec $i: "; adodb_pr($v); adodb_pr($rs->fields); 58 echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true); 59 if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);} 60 else echo "passed<br>"; 51 61 flush(); 52 62 } … … 54 64 55 65 if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); 56 66 else echo "Count $i is correct<br>"; 57 67 58 68 $rs = $db->Execute("select bad from badder"); … … 65 75 66 76 $rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id"); 67 echo "Result=\n",$rs; 77 echo "Result=\n",$rs,"</p>"; 78 79 echo "<h3>Active Record</h3>"; 80 try { 81 include_once("../adodb-active-record.inc.php"); 82 class City extends ADOdb_Active_Record{}; 83 $a = new City(); 84 85 } catch(exception $e){ 86 echo $e->getMessage(); 87 } 88 89 try { 90 91 ADOdb_Active_Record::SetDatabaseAdapter($db); 92 $a = new City(); 93 94 echo "<p>Successfully created City()<br>"; 95 var_dump($a->GetPrimaryKeys()); 96 $a->city = 'Kuala Lumpur'; 97 $a->Save(); 98 $a->Update(); 99 $a->SetPrimaryKeys(array('city')); 100 $a->country = "M'sia"; 101 $a->save(); 102 $a->Delete(); 103 } catch(exception $e){ 104 echo $e->getMessage(); 105 } 106 107 include_once("test-active-record.php"); 68 108 ?>
Note: See TracChangeset
for help on using the changeset viewer.