-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexampleObjects.php
More file actions
50 lines (35 loc) · 1.31 KB
/
exampleObjects.php
File metadata and controls
50 lines (35 loc) · 1.31 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
<?php
ini_set('display_errors', '1');
require "smartSql.php";
/*
Example smartSql objects
*/
// SELECT query
$selectQuery = new smartSql("select", "levels");
$selectQuery->initSelectVars(["Level_ID", "game", "stars"]);
$selectQuery->addWhere("Level_ID", 231);
$finalSelectQuery = $selectQuery->build();
// UPDATE query
$updateQuery = new smartSql("update", "scores");
$updateQuery->initSet("score", 9021);
$updateQuery->initSet("time", time());
$updateQuery->addWhere("Level_ID", 231);
$finalUpdateQuery = $updateQuery->build();
// Another SELECT query
// Not calling the initSelectVars function, to use the default "*" value
$selectQueryTwo = new smartSql("SELECT", "levels");
$selectQueryTwo->initLimit(20, 40);
$selectQueryTwo->addWhere("Title", "cool", "LIKE", false);
$finalSelectQueryTwo = $selectQueryTwo->build();
// Yet another SELECT query
$selectQueryThr = new smartSql("SELECT", "levels");
$selectQueryThr->addWhere("game", "gooberTime");
$selectQueryThr->initOrder("Level_ID", "ASC");
$finalSelectQueryThr = $selectQueryThr->build();
?>
<html>
<div>Select query: <?= $finalSelectQuery ?></div>
<div>Update query: <?= $finalUpdateQuery ?></div>
<div>Select query: <?= $finalSelectQueryTwo ?></div>
<div>Select query: <?= $finalSelectQueryThr ?></div>
</html>