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

« back to all changes in this revision

Viewing changes to lib/adodb/tests/test4.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
1
<?php
2
2
 
3
3
/** 
4
 
 * @version V4.20 22 Feb 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
 
4
 * @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
5
5
 * Released under both BSD license and Lesser GPL library license. 
6
6
 * Whenever there is any discrepancy between the two licenses, 
7
7
 * the BSD license will take precedence. 
31
31
// Select an empty record from the database 
32
32
 
33
33
$conn = &ADONewConnection("mysql");  // create a connection
 
34
$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb
 
35
 
 
36
//$conn =& ADONewConnection('oci8');
 
37
//$conn->Connect('','scott','natsoft');
34
38
//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
35
39
 
36
40
$conn->debug=1;
37
 
$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb
38
41
$conn->Execute("delete from adoxyz where lastname like 'Smith%'");
39
42
 
40
43
$rs = $conn->Execute($sql); // Execute the query and get the empty recordset
53
56
 
54
57
$conn->Execute($insertSQL); // Insert the record into the database
55
58
 
 
59
$insertSQL2 = $conn->GetInsertSQL($table='ADOXYZ', $record);
 
60
if ($insertSQL != $insertSQL2) echo "<p><b>Walt's new stuff failed</b>: $insertSQL2</p>";
56
61
//==========================
57
62
// This code tests an update
58
63
 
59
64
$sql = "
60
65
SELECT * 
61
 
FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']); 
 
66
FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']). " ORDER BY 1"; 
62
67
// Select a record to update 
63
68
 
64
69
$rs = $conn->Execute($sql); // Execute the query and get the existing record to update
65
 
if (!$rs) print "<p>No record found!</p>";
 
70
if (!$rs) print "<p><b>No record found!</b></p>";
66
71
 
67
72
$record = array(); // Initialize an array to hold the record data to update
68
73
 
78
83
$updateSQL = $conn->GetUpdateSQL($rs, $record);
79
84
 
80
85
$conn->Execute($updateSQL); // Update the record in the database
81
 
print "<p>Rows Affected=".$conn->Affected_Rows()."</p>";
 
86
if ($conn->Affected_Rows() != 1)print "<p><b>Error</b>: Rows Affected=".$conn->Affected_Rows().", should be 1</p>";
82
87
 
83
88
$rs = $conn->Execute("select * from adoxyz where lastname like 'Smith%'");
84
89
adodb_pr($rs);