This function executes an SQL statement a on the database that alias b represents. Placeholders of the form ¶mNumber in the statement are replaced by the values starting with parameter c. Characters needed for a valid syntax, such as quotes around strings, must be part of the statement already. If the database returns no result, the function returns false. Otherwise, it returns true.
IMPORTANT:
In addition to the notation
¶mNumber, you can use the notation for prepared statements, in the form@parameterNumber:parameterType@. Prefer this notation because it prevents SQL injection attacks. Within prepared statements, parameters replace single values only. SQL syntax such as value lists forIN, table or column names, operators, sort orders, or complete SQL fragments cannot be passed via placeholders.
Parameters
Parameter | Description |
|---|---|
a | SQL statement to be called. |
b | Database alias. |
c | (optional) Parameter |
d | (optional) Parameter |
e | (optional) Parameter |
f | (optional) Parameter |
g | (optional) Parameter |
h | (optional) Parameter |
i | (optional) Parameter |
j | (optional) Parameter |
k | (optional) |
l | (optional) If |
Examples
A table zipcodes containing all zip codes of Germany is given.
Parameter a | b | c | d | e…j | k | l | Result |
|---|---|---|---|---|---|---|---|
select * from zipcodes | testdb | true | |||||
select * from zipcodes where zipcode = &1 | testdb | 80336 | true | ||||
select * from zipcodes where city = '&2' | testdb | Munich | true | ||||
select * from zipcodes where zipcode = &1 and city = '&2' | testdb | 12345 | Munich | false |
NOTE:
The call automatically limits the database result to one row at maximum, independent of how many rows exist. It is therefore not necessary to add a
LIMITclause to the statement.If you need the actual values afterward, retrieve them directly with one of the select functions. Then check whether a returned value exists.