-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest.php
More file actions
127 lines (114 loc) · 2.41 KB
/
test.php
File metadata and controls
127 lines (114 loc) · 2.41 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
require_once("EasyPDO.php");
$db = new EasyPDO('mysql:dbname=dummy;host=localhost;charset=UTF8', 'root', '');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>EasyPDO - PHP PDO Wrapper Class</title>
</head>
<h2>Test 1: select</h2>
<pre>
<?php
$data = $db->select('dummy', '*', 'id<:max', array(':max'=>100), "id ASC", "0, 3");
print_r($data);
?>
</pre>
<h2>Test 2: insert</h2>
<pre>
<?php
$data = array(
'inf1' => 'test2',
'inf2' => 'insert'
);
$db->insert('dummy', $data);
$data = $db->select('dummy', '*', "inf1='test2'");
print_r($data);
?>
</pre>
<h2>Test 3: update</h2>
<pre>
<?php
$data = array(
'inf1' => 'test3',
'inf2' => 'update'
);
$data = $db->update('dummy', $data, 'id=:id', array(':id' => 3));
$data = $db->select('dummy', '*', 'id=:id', array(':id' => 3));
print_r($data);
?>
</pre>
<h2>Test 4: delete</h2>
<pre>
<?php
$db->delete('dummy', "inf1=:inf1" , array(':inf1' => 'test2'));
$data = $db->select('dummy', '*', "inf1=:inf1" , array(':inf1' => 'test2'));
print_r($data);
?>
</pre>
<h2>Test 5: save</h2>
<pre>
<?php
$data = array(
'inf1' => 'test5',
'inf2' => 'save'.rand(1, 100)
);
$db->save('dummy', $data, "inf1=:inf1" , array(':inf1' => 'test5'));
$data = $db->select('dummy', '*', "inf1=:inf1", array('inf1'=>'test5'));
print_r($data);
?>
</pre>
<?php
$sql = "SELECT id, inf1, inf2 FROM dummy WHERE id BETWEEN :start AND :end ORDER BY id";
$bind = array(
':start' => 1,
':end' => 3
);
?>
<h2>Test 6: fetchOne</h2>
<pre>
<?php
$data = $db->fetchOne($sql, $bind);
print_r($data);
?>
</pre>
<h2>Test 6: fetchRow</h2>
<pre>
<?php
$data = $db->fetchRow($sql, $bind);
print_r($data);
?>
</pre>
<h2>Test 7: fetchAll</h2>
<pre>
<?php
$data = $db->fetchAll($sql, $bind);
print_r($data);
?>
</pre>
<h2>Test 8: fetchAssoc</h2>
<pre>
<?php
$data = $db->fetchAssoc($sql, $bind);
print_r($data);
?>
</pre>
<h2>Test 9: fetchPairs</h2>
<pre>
<?php
$sql = "SELECT inf1, inf2 FROM dummy WHERE id BETWEEN :start AND :end ORDER BY id";
$data = $db->fetchPairs($sql, $bind);
print_r($data);
?>
</pre>
<h2>Test 9: fetchCol</h2>
<pre>
<?php
$sql = "SELECT inf1 FROM dummy WHERE id BETWEEN :start AND :end ORDER BY id";
$data = $db->fetchCol($sql, $bind);
print_r($data);
?>
</pre>
<body>
</html>