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
Super MySQL is an easy-to-use powerful SQL query builder.
1
+
# SuperSQL
2
+
SuperSQL is an easy-to-use powerful SQL query builder for SQLite and MySQL.
3
3
4
4
## Requirements
5
5
* PHP 5.6+
6
-
* MySQL
7
-
* PDO MySQL extension
6
+
* PDO SQLite / MySQL driver
8
7
9
8
## Examples
10
9
Let’s have a table “<strong>users</strong>” with 5 columns: `uid`, `username`, `password`, `sign_up_time` and `nickname`
11
10
12
11
```php
13
12
<?php
14
-
include "smysql.php";
13
+
include "ssql.php";
15
14
16
-
//Connect with new Smysql($host, $user, $password[, $database])
17
-
$smysql = new Smysql("localhost", "root", "root", "db");
15
+
//Connect with new Ssql($host[, $user[, $password[, $database]]])
16
+
$ssql = new Ssql("localhost", "root", "root", "db");
18
17
19
-
//To execute raw SQL query use $smysql->q($q[, $a]), FETCH_ALL returns an array of rows, FETCH_OBJECT and FETCH_ARRAY return one row per call
20
-
$smysql->q("SELECT * FROM users")->fetch(SMQ::FETCH_ALL);
18
+
//Connect to SQLite with just the first parameter
19
+
$ssql = new Ssql("db.sqlite");
20
+
21
+
//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
22
+
$ssql->q("SELECT * FROM users")->fetch(SMQ::FETCH_ALL);
21
23
22
24
//You can use wildcards for escaping
23
-
$smysql->q("SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1", [$name, $nick])->fetch();
25
+
$ssql->q("SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1", [$name, $nick])->fetch();
24
26
25
27
//You can use queries as methods
26
-
$smysql->getUser = "SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1";
27
-
$user = $smysql->getUser($name, $nick)->fetch();
28
+
$ssql->getUser = "SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1";
29
+
$user = $ssql->getUser($name, $nick)->fetch();
28
30
29
-
//For simple requests use $smysql->read($table[, $flags]) or $smysql->read($table, $cond[, $flags])
31
+
//For simple requests use $ssql->read($table[, $flags]) or $ssql->read($table, $cond[, $flags])
30
32
//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
0 commit comments