/
Example.php
53 lines (36 loc) · 1.19 KB
/
Example.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
<pre>
<?php
include "sqli.php";
// Connect to the database
$sqli = new sqli(["127.0.0.1", "", "", "test"]);
// Insert three rows to have some data to play with
$insert1 = $sqli->push("insert into test (msg) VALUES (?)", "s", "Just a test");
echo "Insert id:" . $insert1->id."\n";
$insert2 = $sqli->push("insert into test (msg) VALUES (?)", "s", "Just a test");
echo "Insert id:" . $insert2->id."\n";
$insert3 = $sqli->push("insert into test (msg) VALUES (?)", "s", "Just a test");
echo "Insert id:" . $insert3->id."\n\n";
// Show the data form the array
foreach ($sqli->pull_multiple("SELECT id, msg as message FROM test")->data as $row) {
echo $row['id']." : ".$row['message']."\n";
}
echo "\n";
// Show one row
echo "First insert row: ".$sqli->pull_once("SELECT msg as message FROM test WHERE id=?", "i", $insert1->id)->data['message']."\n";
// Clere the table
echo "Deleted rows:".$sqli->push("DELETE FROM test")->affected_rows."\n";
// Some rows left?
echo "Rows left: ".$sqli->pull_multiple("SELECT * FROM test")->count;
/* HERES MY OUTPUT
Insert id:1
Insert id:2
Insert id:3
1 : Just a test
2 : Just a test
3 : Just a test
First insert row: Just a test
Deleted rows:3
Rows left: 0
*/
?>
</pre>