Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added documentation for advanced conditions
  • Loading branch information
ratajs authored Sep 28, 2021
1 parent 223e596 commit d4ed882
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,28 @@ Here is list of all SuperSQL flags:
], "number");

//Use $ssql->deleteTable($table[, $flags]) to delete a table
$c->deleteTable("myTable");
$ssql->deleteTable("myTable");

//To see a list of all tables in your database use $ssql->tableList([$flags])
print_r($c->tableList());
print_r($ssql->tableList());


//Advanced conditions


//You can use more advanced conditions with $ssql->cond(), this will select users that have the same username and nickname signed up in the last hour
$ssql->read("users", $ssql->cond()->eq("username", "nickname")->gte("sign_up_time", time() - 3600));

//Use arrays to differentiate string values from column names and to specify more alternatives, the COND_OR flag is also supported
//This will select users that have username either "ratajs" or "admin" or that have username "RatajS"
$ssql->read("users", $ssql->cond()->eq("username", ["ratajs", "admin"])->eq("nickname", ["RatajS"], SQ::COND_OR));

//->not negates the condition, this will select users with usernames other than admin
$ssql->read("users", $ssql->cond()->eq("username", ["admin"])->not());

//It can also add another condition, this will select user that don’t have any nickname and with username other that "admin" or "root".
$ssql->read("users", $ssql->cond()->eq("nickname", [""])->not($ssql->cond()->eq("username", ["admin", "root"])));

//Supported condition functions: ->eq(), ->lt(), ->gt(), ->lte(), ->gte(), ->like() and ->between()
?>
```

0 comments on commit d4ed882

Please sign in to comment.