Skip to content

Commit df07c83

Browse files
authored
Update README.md
1 parent 8012893 commit df07c83

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Let’s have a table “<strong>users</strong>” with 5 columns: `uid`, `userna
1313
include "ssql.php";
1414

1515
//Connect with new Ssql($host[, $user[, $password[, $database]]])
16-
$ssql = new Ssql("localhost", "root", "root", "db");
16+
$ssql = new Ssql("localhost", "root", "root", "db"); // MySQL
1717

1818
//Connect to SQLite with just the first parameter
1919
$ssql = new Ssql("db.sqlite");
2020

2121
//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);
22+
$ssql->q("SELECT * FROM users")->fetch(SQ::FETCH_ALL);
2323

2424
//You can use wildcards for escaping
2525
$ssql->q("SELECT * FROM users WHERE `username`=%0 OR `nickname`=%1", [$name, $nick])->fetch();
@@ -30,23 +30,23 @@ Let’s have a table “<strong>users</strong>” with 5 columns: `uid`, `userna
3030

3131
//For simple requests use $ssql->read($table[, $flags]) or $ssql->read($table, $cond[, $flags])
3232
//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
33-
$users = $ssql->read("users", SMQ::FETCH_ALL);
33+
$users = $ssql->read("users", SQ::FETCH_ALL);
3434
$user = $ssql->read("users", ['uid' => $id]);
3535

3636
//You can use more conditions
3737
$user = $ssql->read("users", ['username' => $name, 'password' => $pass]);
3838

3939
//You can use the COND_OR flag for OR operator instead of AND
40-
$user = $ssql->read("users", ['username' => $name, 'nickname' => $nick], SMQ::FETCH_ALL | SMQ::COND_OR)[0];
40+
$user = $ssql->read("users", ['username' => $name, 'nickname' => $nick], SQ::FETCH_ALL | SQ::COND_OR)[0];
4141

4242
//You can use custom conditions
4343
$users = $ssql->read("users", "`sign_up_time` > " . bcsub(time(), 3600));
4444

4545
//You can use more of them
46-
$users = $ssql->read("users", ["`sign_up_time` > " . bcsub(time(), 3600), "`nickname` IS NOT NULL"], SMQ::FETCH_ALL);
46+
$users = $ssql->read("users", ["`sign_up_time` > " . bcsub(time(), 3600), "`nickname` IS NOT NULL"], SQ::FETCH_ALL);
4747

4848
//For more complicated requests use $ssql->select($table[, $order[, $cols[, $limit[, $flags]]]]), you can use array keys for aliases
49-
$users = $ssql->select("users", "sign_up_time", ['id' => "uid", 'name' => "username", "sign_up_time", "nickname"], NULL, SMQ::ORDER_DESC)->fetch(SMQ::FETCH_ALL);
49+
$users = $ssql->select("users", "sign_up_time", ['id' => "uid", 'name' => "username", "sign_up_time", "nickname"], NULL, SQ::ORDER_DESC)->fetch(SQ::FETCH_ALL);
5050

5151
//Or $ssql->selectWhere($table, $cond[, $order[, $cols[, $limit[, $flags]]]])
5252
$user = $ssql->selectWhere("users", ['uid' => $id], "name", ['id' => "uid", 'name' => "username", "sign_up_time", 'nick' => "nickname"])->fetch();
@@ -61,7 +61,7 @@ Let’s have a table “<strong>users</strong>” with 5 columns: `uid`, `userna
6161
$ssql->insert("users", ['username' => $name, 'password' => $pass, 'sign_up_time' => time()]);
6262

6363
//You can use INSERT_RETURN_ID flag for returning the first auto increment col value (depends on the database type)
64-
$id = $ssql->insert("users", ['username' => $name, 'password' => $pass, 'sign_up_time' => time()], SMQ::INSERT_RETURN_ID);
64+
$id = $ssql->insert("users", ['username' => $name, 'password' => $pass, 'sign_up_time' => time()], SQ::INSERT_RETURN_ID);
6565

6666
//Use $ssql->update($table, $cond, $values[, $flags]) to update rows
6767
$ssql->update("users", ['id' => $id], ['nickname' => $nick]);
@@ -112,11 +112,11 @@ Here is list of all SuperSQL flags:
112112

113113

114114
//Use $ssql->selectJoin($table, $join, $on[, $order[, $cols[, $limit[, $flags]]]]) to execute a JOIN command
115-
$result = $ssql->selectJoin("users", "messages", ['from_user' => 'uid'], "time", "*", 5, SMQ::ORDER_DESC)->fetch(SMQ::FETCH_ALL);
115+
$result = $ssql->selectJoin("users", "messages", ['from_user' => 'uid'], "time", "*", 5, SQ::ORDER_DESC)->fetch(SQ::FETCH_ALL);
116116
//Use JOIN_LEFT, JOIN_RIGHT and JOIN_FULL flags to other types of JOIN
117117

118118
//To combine JOIN and WHERE use $ssql->selectJoinWhere($table, $join, $on, $cond[, $order[, $cols[, $limit[, $flags]]]])
119-
$result = $ssql->selectJoinWhere("users", "messages", ['from_user' => 'uid'], ['from_user' => $uid])->fetch(SMQ::FETCH_ALL);
119+
$result = $ssql->selectJoinWhere("users", "messages", ['from_user' => 'uid'], ['from_user' => $uid])->fetch(SQ::FETCH_ALL);
120120

121121

122122

0 commit comments

Comments
 (0)