[Top]
Sql
Sql.Sql
|
Method Sql.Sql()->query()
- Method
query
-
array(mapping(string:mixed)) query(object|string q, mixed ... extraargs)
- Description
-
Send an SQL query to the underlying SQL-server.
- Parameter q
-
Query to send to the SQL-server. This can either be a string with the
query, or a previously compiled query (see compile_query()).
- Parameter extraargs
-
This parameter, if specified, can be in two forms:
A mapping containing bindings of variables used in the query.
A variable is identified by a colon (:) followed by a name or number.
Each index in the mapping corresponds to one such variable, and the
value for that index is substituted (quoted) into the query wherever
the variable is used.
mixed err = catch {
query("SELECT foo FROM bar WHERE gazonk=:baz",
([":baz":"value"]));
};
if(!intp(err))
werror("An error occured.");
Binary values (BLOBs) may need to be placed in multisets.
Arguments as you would use in sprintf. They are automatically
quoted.
query("select foo from bar where gazonk=%s","value") )
- Returns
-
Returns one of the following on success:
array(mapping(string:string)) | The result as an array of mappings indexed on the name
of the columns
|
zero | The value 0 (zero) if the query didn't return any
result (eg INSERT or similar).
|
|
- Throws
-
Throws an exception if the query fails.
|