Skip to content

Commit

Permalink
Update JSMF-Database-Query.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan authored Oct 6, 2017
1 parent 364ffdf commit 3ded134
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions JSMF-Database-Query.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ add WHERE clause to select, update, delete commands
* $queries **Array**
* $params **Array** - <p>(the PDO params used in the queries)</p>

#### Example for $queries
$queries = [
[ 'alias.fieldname', '=?'],
'AND',
[ 'alias.fieldname2', 'IS NOT NULL', 'OR', [
['alias.fieldname3', 'IS NULL'],
'AND'
['alias.fieldname4', 'LIKE "%foo"']
]
],
]

This will result in a WHERE clause like:
WHERE (alias.fieldname=?) AND (alias.fieldname2 IS NOT NULL OR (alias.fieldname3 IS NULL AND alias.fieldname4 LIKE "%foo"))

Queries can be nested as deep as needed by nesting the array too (example with fieldname3 and fieldname4)
Each part of the query that is an own array will be surrounded by brackets

It looks more complicated than writing the query by hand, but with this technique the database class can ensure the correct COLLATION for each field




### orderBy
Expand Down

0 comments on commit 3ded134

Please sign in to comment.