Ignore:
Timestamp:
06/29/07 15:17:46 (17 years ago)
Author:
niltonneto
Message:

Versão nova do ADODB (4.5 para 4.95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/adodb/tests/test-php5.php

    r2 r34  
    11<?php 
    22/* 
    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. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    1919try { 
    2020 
    21 $dbt = 'oci8po'; 
     21$dbt = 'mysql'; 
    2222 
     23try { 
    2324switch($dbt) { 
    2425case 'oci8po': 
    2526        $db = NewADOConnection("oci8po"); 
     27         
    2628        $db->Connect('','scott','natsoft'); 
    2729        break; 
     
    2931case 'mysql': 
    3032        $db = NewADOConnection("mysql"); 
    31         $db->Connect('localhost','root','','test'); 
     33        $db->Connect('localhost','root','','northwind'); 
    3234        break; 
    3335         
    3436case 'mysqli': 
    35         $db = NewADOConnection("mysqli://root:@localhost/test"); 
     37        $db = NewADOConnection("mysqli://root:@localhost/northwind"); 
    3638        //$db->Connect('localhost','root','','test'); 
    3739        break; 
     40} 
     41} catch (exception $e){ 
     42        echo "Connect Failed"; 
     43        adodb_pr($e); 
     44        die(); 
    3845} 
    3946 
     
    4552$rs = $db->Execute($stmt,array(10,20)); 
    4653 
     54echo  "<hr /> Foreach Iterator Test (rand=".rand().")<hr />"; 
    4755$i = 0; 
    48 foreach($rs as  $v) { 
     56foreach($rs as $v) { 
    4957        $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>"; 
    5161        flush(); 
    5262} 
     
    5464 
    5565if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); 
    56  
     66else echo "Count $i is correct<br>"; 
    5767 
    5868$rs = $db->Execute("select bad from badder"); 
     
    6575 
    6676$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id"); 
    67 echo "Result=\n",$rs; 
     77echo "Result=\n",$rs,"</p>"; 
     78 
     79echo "<h3>Active Record</h3>"; 
     80try { 
     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 
     89try { 
     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 
     107include_once("test-active-record.php"); 
    68108?> 
Note: See TracChangeset for help on using the changeset viewer.