On 01/06/2013 07:21 PM, Daniel Gruno wrote:
> On 01/06/2013 04:23 PM, Stefan Fritsch wrote:
>> On Sun, 6 Jan 2013, Daniel Gruno wrote:
> -- Regular prepared statement creation:
> local prepped, err = db:prepare("SELECT * FROM `tbl` WHERE `id` = %s")
> if not err then
>     local result, err = prepped("foobar") -- insert foobar as id
>     ...
> end
> 
> -- Fetch from DBDPrepareSQL:
> local prepped, err = db:prepared("someTag")
> if not err then
>     local result, err = prepped("foobar") -- insert foobar as id
>     ...
> end
> 

One last change before I commit the code; prepared statements now have
two functions identical to the database object; select and query. These
were formerly known as query and run in the db object, but I have
renamed them to comply with the naming conventions of apr_dbd, thus
'query' is for running a command and fetching the no. of rows affected,
and 'select' is for...selecting :)

So, prepared statements are now run as follows:

-- select stuff
local prepared, err = db:prepare("SELECT * FROM `tbl` WHERE `age` > %u")
if not err then
    local result, err = prepared:select(1234)
    ....
end

-- run stuff
local prepared, err = db:prepare("DELETE FROM `tbl` WHERE `age` > %u")
if not err then
    local result, err = prepared:query(1234)
    ....
end

With regards,
Daniel.

Reply via email to