~ubuntu-branches/ubuntu/hoary/moodle/hoary

« back to all changes in this revision

Viewing changes to lib/adodb/tests/test-php5.php

  • Committer: Bazaar Package Importer
  • Author(s): Isaac Clerencia
  • Date: 2004-12-29 00:49:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041229004952-gliyqzpj2w3e7clx
Tags: 1.4.3-1
* Urgency high as upstream release fixes several security bugs
* New upstream release
* Write database creation errors and warn the user about it, 
closes: #285842, #285842

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
  V4.20 22 Feb 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). 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
 
 
11
 
error_reporting(E_ALL);
12
 
 
13
 
$path = dirname(__FILE__);
14
 
 
15
 
include("$path/../adodb-exceptions.inc.php");
16
 
include("$path/../adodb.inc.php");      
17
 
 
18
 
echo "<h3>PHP ".PHP_VERSION."</h3>\n";
19
 
try {
20
 
 
21
 
$dbt = 'oci8';
22
 
 
23
 
switch($dbt) {
24
 
case 'oci8':
25
 
        $db = NewADOConnection("oci8");
26
 
        $db->Connect('','scott','natsoft');
27
 
        break;
28
 
default:
29
 
case 'mysql':
30
 
        $db = NewADOConnection("mysql");
31
 
        $db->Connect('localhost','root','','test');
32
 
        break;
33
 
}
34
 
 
35
 
$db->debug=1;
36
 
 
37
 
$cnt = $db->GetOne("select count(*) from adoxyz");
38
 
$rs = $db->Execute("select * from adoxyz order by id");
39
 
 
40
 
$i = 0;
41
 
foreach($rs as  $v) {
42
 
        $i += 1;
43
 
        echo "$i: "; adodb_pr($v); adodb_pr($rs->fields);
44
 
        flush();
45
 
}
46
 
 
47
 
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
48
 
 
49
 
 
50
 
$rs = $db->Execute("select bad from badder");
51
 
 
52
 
} catch (exception $e) {
53
 
        adodb_pr($e);
54
 
        echo "<h3>adodb_backtrace:</h3>\n";
55
 
        $e = adodb_backtrace($e->gettrace());
56
 
}
57
 
 
 
1
<?php
 
2
/*
 
3
  V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). 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
 
 
11
error_reporting(E_ALL);
 
12
 
 
13
$path = dirname(__FILE__);
 
14
 
 
15
include("$path/../adodb-exceptions.inc.php");
 
16
include("$path/../adodb.inc.php");      
 
17
 
 
18
echo "<h3>PHP ".PHP_VERSION."</h3>\n";
 
19
try {
 
20
 
 
21
$dbt = 'oci8po';
 
22
 
 
23
switch($dbt) {
 
24
case 'oci8po':
 
25
        $db = NewADOConnection("oci8po");
 
26
        $db->Connect('','scott','natsoft');
 
27
        break;
 
28
default:
 
29
case 'mysql':
 
30
        $db = NewADOConnection("mysql");
 
31
        $db->Connect('localhost','root','','test');
 
32
        break;
 
33
        
 
34
case 'mysqli':
 
35
        $db = NewADOConnection("mysqli://root:@localhost/test");
 
36
        //$db->Connect('localhost','root','','test');
 
37
        break;
 
38
}
 
39
 
 
40
$db->debug=1;
 
41
 
 
42
$cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));
 
43
$stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");
 
44
if (!$stmt) echo $db->ErrorMsg(),"\n";
 
45
$rs = $db->Execute($stmt,array(10,20));
 
46
 
 
47
$i = 0;
 
48
foreach($rs as  $v) {
 
49
        $i += 1;
 
50
        echo "rec $i: "; adodb_pr($v); adodb_pr($rs->fields);
 
51
        flush();
 
52
}
 
53
 
 
54
 
 
55
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
 
56
 
 
57
 
 
58
$rs = $db->Execute("select bad from badder");
 
59
 
 
60
} catch (exception $e) {
 
61
        adodb_pr($e);
 
62
        echo "<h3>adodb_backtrace:</h3>\n";
 
63
        $e = adodb_backtrace($e->gettrace());
 
64
}
 
65
 
 
66
$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
 
67
echo "Result=\n",$rs;
58
68
?>
 
 
b'\\ No newline at end of file'