Building Queries¶
dbPrepareQuery [query, bindValues]¶
Prepares a query and directly binds some values to it.
query: | <STRING> - The SQL Query String |
---|---|
bindValues: | <ARRAY> - List of values to bind to ? in the query string. See dbBindValueArray for more information. |
Returns: <QUERY>
dbPrepareQuery ["SELECT ? FROM ? WHERE ?=?", ["data", "table", "value", 5]]
SELECT data FROM table WHERE value=5
dbPrepareQueryConfig configName¶
Prepares a query based on details in the config file in statements.<configName>
configName: | <STRING> - The config name of the query |
---|
Attention
configName is case-sensitive
Returns: <QUERY>
dbPrepareQueryConfig [configName, bindValues]¶
Prepares a query based on details in the config file in statements.<configName>
configName: | <STRING> - The config name of the query |
---|---|
bindValues: | <ARRAY> - List of values to bind to ? in the query string (See above) |
Attention
configName is case-sensitive
Returns: <QUERY>
query dbBindValue value¶
query: | <QUERY> |
---|---|
value: | <STRING> OR <NUMBER> OR <BOOL> OR <ARRAY> - Value to bind to the next unbound ? in the query |
Returns: <NOTHING>
Note
ARRAY values are automatically converted to string. Meaning [1,2,3]
will get bound as "[1,2,3]"
Warning
This command modifies the value in query
. If you want to keep the old query intact you need to dbCopyQuery first.
query dbBindValueArray [value, value…]¶
Binds multiple values to the next ?
in the query, in same order as the ?
occur in the query.
query: | <QUERY> |
---|---|
value: | <STRING> OR <NUMBER> OR <BOOL> OR <ARRAY> - Value to bind to the next unbound ? in the query |
Returns: <NOTHING>
Note
ARRAY values are automatically converted to string. Meaning [1,2,3]
will get bound as "[1,2,3]"
Warning
This command modifies the value in query. If you want to keep the old query intact you need to dbCopyQuery first.
Example: _query = dbPrepareQuery "SELECT ? FROM ? WHERE ?=?"
_query dbBindValueArray ["data", "table", "value", 5]
-> SELECT data FROM table WHERE value=5
dbGetBoundValues query¶
Returns array of all values currently bound to this query
returns <ARRAY>
dbCopyQuery query¶
query: <QUERY>
- the query object returned by dbPrepareQuery
Tip
There is also the short version + query
which copies just like with Arrays and Numbers.
Returns: <NOTHING>
_query = dbPrepareQuery "SELECT ? FROM ? WHERE ?=?"
_query dbBindValueArray ["data", "table"]
SELECT data FROM table WHERE ?=?
_copyOfQuery = dbCopyQuery _query;
SELECT data FROM table WHERE ?=?
_copyOfQuery dbBindValueArray ["value", 5]
SELECT data FROM table WHERE value=5
SELECT data FROM table WHERE ?=?