/
adodb_conn_close.php
62 lines (50 loc) · 1.45 KB
/
adodb_conn_close.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
// Section 1
include("/usr/share/php/adodb/adodb.inc.php");
// $db = newADOConnection('pdo');
// $db = ADOnewConnection('pdo');
$db = newADOConnection('mysqli');
// $db->debug = true;
// $db->connect("mysql", "root", "password", "mydb");
$db->Connect("mysql", "root", "password", "mydb");
// $user = 'root';
// $password = 'password';
// $dsnString= 'host=mysql;dbname=employeesclose;charset=utf8mb4';
// $db->connect('mysql:' . $dsnString,$user,$password);
$createQuery = "CREATE TABLE IF NOT EXISTS employeesclose(id int(11) NOT NULL auto_increment, empid varchar(250) NOT NULL default '', PRIMARY KEY(id))";
$db->Execute($createQuery);
for ($i=0; $i < 50; $i++) {
$db->Execute("INSERT INTO employeesclose(empid) values('YES')");
}
printf ("Added 50 Yes");
for ($i=0; $i < 2; $i++) {
$db->Execute("INSERT INTO employeesclose(empid) values('ABC')");
}
printf ("Added 2 NO");
// Section 2
$result = $db->Execute("SELECT * FROM employeesclose where empid='YES'");
if ($result === false) die("failed");
// Section 3
while (!$result->EOF) {
for ($i=0, $max=$result->fieldCount(); $i < $max; $i++) {
print $result->fields[$i].' ';
}
$result->moveNext();
print "<br>\n";
}
$db->Close();
print "<br>\n";
print "<br>\n";
print "<br>\n";
if ($db->IsConnected) {
print("Connected");
} else {
print("Not Connected");
}
print "<br>\n";
print "<br>\n";
print "<br>\n";
for ($i=0; $i < 500; $i++) {
print("just looping");
}
?>