You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+20-4
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ SuperSQL is an easy-to-use powerful SQL query builder for SQLite and MySQL.
6
6
* PDO SQLite / MySQL driver
7
7
8
8
## Setup
9
-
* Download the <em>ssql.php</em> file ([https://raw.githubusercontent.com/ratajs/SuperSQL/2.1/ssql.php](https://raw.githubusercontent.com/ratajs/SuperSQL/2.1/ssql.php))
9
+
* Download the <em>ssql.php</em> file ([https://raw.githubusercontent.com/ratajs/SuperSQL/2.2/ssql.php](https://raw.githubusercontent.com/ratajs/SuperSQL/2.2/ssql.php))
10
10
* Include the file with `include` / `require`
11
11
12
12
## Examples
@@ -20,23 +20,29 @@ Let’s have a table “<strong>users</strong>” with 5 columns: `uid`, `userna
20
20
$ssql = new Ssql("localhost", "root", "root", "db"); // MySQL
21
21
22
22
//Connect to SQLite with just the first parameter
23
-
$ssql = new Ssql("db.sqlite");
23
+
$ssql = new Ssql("db.sqlite3");
24
24
25
25
//To execute raw SQL query use $ssql->q($q[, $a]), FETCH_ALL returns an array of rows, FETCH_OBJECT and FETCH_ARRAY return one row per call
26
26
$ssql->q("SELECT * FROM users")->fetch(SQ::FETCH_ALL);
27
27
28
28
//You can use wildcards for escaping
29
29
$ssql->q("SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1", [$name, $nick])->fetch();
30
30
31
+
//You can set the object‐wide $debug property to print all queries before being executed
32
+
$ssql->debug = true;
33
+
31
34
//You can use queries as methods
32
35
$ssql->getUser = "SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1";
33
36
$user = $ssql->getUser($name, $nick)->fetch();
34
37
35
-
//For simple requests use $ssql->read($table[, $flags]) or $ssql->read($table, $cond[, $flags])
38
+
//For simple requests use $ssql->read($table[, $cond][, $flags])
36
39
//Read function uses FETCH_SMART as default (FETCH_OBJECT for one row, FETCH_ALL for more), so you need to use the FETCH_ALL flag to return an array even when there is only one result
37
40
$users = $ssql->read("users", SQ::FETCH_ALL);
38
41
$user = $ssql->read("users", ['uid' => $id]);
39
42
43
+
//You can use the DEBUG flag to print this query before execution
0 commit comments