source: tmp/version-2_5-test/data/module/adodb/tests/test-php5.php @ 18609

Revision 18609, 2.4 KB checked in by kajiwara, 14 years ago (diff)

正式版にナイトリービルド版をマージしてみるテスト

Line 
1<?php
2/*
3  V4.81 3 May 2006  (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
4  Released under both BSD license and Lesser GPL library license.
5  Whenever there is any discrepancy between the two licenses,
6  the BSD license will take precedence.
7  Set tabs to 8.
8 */
9
10
11error_reporting(E_ALL);
12
13$path = dirname(__FILE__);
14
15include("$path/../adodb-exceptions.inc.php");
16include("$path/../adodb.inc.php"); 
17
18echo "<h3>PHP ".PHP_VERSION."</h3>\n";
19try {
20
21$dbt = 'mysql';
22
23try {
24switch($dbt) {
25case 'oci8po':
26    $db = NewADOConnection("oci8po");
27   
28    $db->Connect('','scott','natsoft');
29    break;
30default:
31case 'mysql':
32    $db = NewADOConnection("mysql");
33    $db->Connect('localhost','root','','northwind');
34    break;
35   
36case 'mysqli':
37    $db = NewADOConnection("mysqli://root:@localhost/northwind");
38    //$db->Connect('localhost','root','','test');
39    break;
40}
41} catch (exception $e){
42    echo "Connect Failed";
43    adodb_pr($e);
44    die();
45}
46
47$db->debug=1;
48
49$cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));
50$stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");
51if (!$stmt) echo $db->ErrorMsg(),"\n";
52$rs = $db->Execute($stmt,array(10,20));
53
54echo  "<hr /> Foreach Iterator Test (rand=".rand().")<hr />";
55$i = 0;
56foreach($rs as $v) {
57    $i += 1;
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>";
61    flush();
62}
63
64
65if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
66else echo "Count $i is correct<br>";
67
68$rs = $db->Execute("select bad from badder");
69
70} catch (exception $e) {
71    adodb_pr($e);
72    echo "<h3>adodb_backtrace:</h3>\n";
73    $e = adodb_backtrace($e->gettrace());
74}
75
76$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
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");
108?>
Note: See TracBrowser for help on using the repository browser.