<sql> execute raw sql

name
sql
xml namespace
http://moyaproject.com/db

This tag executes raw SQL and returns a results object.

Results objects have the properties rowcount (number of rows matched), rowkeys (list of field names), and fetch (an interface to retrieve results).

You can retrieve all rows with results.fetch.all, or a single row at a time with results.fetch.one. You can get a batch of a rows by using an integer index. For example, results.fetch.10 retrieves the next 10 rows.

If your query returns a scalar value, you can retrieve it with results.fetch.scalar.

Example

<db:sql dst="results" let:username="'John'">
    select * from auth_user where auth_user.username=:username;
</db:sql>
<echo obj="results.fetch.one"/>
attributes
name purpose type required? default choices
bind Parameters to bind to SQL expression No None
db Database text No "_default"
inherited attributes
name purpose type required? default choices
dst Destination reference No
if Conditional expression expression No yes
value Value expression No None