On 01/06/2013 04:23 PM, Stefan Fritsch wrote:
> On Sun, 6 Jan 2013, Daniel Gruno wrote:
>> Now I just have to take a good look at how to rewrite the prepared
>> statement stuff, and I believe I'll have a decent proposal ready for
>> commit :)
>
> I am a bit late in the discussion, but maybe you also want to support
> using statements that have been prepared with DBDPrepareSQL from mod_dbd?
>
> Other important things (but I think these have already been pointed out):
>
> - don't let lua scripts open connections, instead make them aquire
> connections from mod_dbd's connection pool.
>
> - use parametrized prepared statements in all examples and make that as
> easy to use as possible. Don't show any examples that put parameters
> directly into the statement strings.
First off, I should mention that mod_dbd is indeed supported in the
proposal, in fact, I use only mod_dbd for my own Lua stuff.
As per our discussion on IRC, I have made some additions to the prepared
statements, so that statements prepared using DBDPrepareSQL can also be
fetched using db:prepared(r, tag). Thus prepared statements can be used
in two ways:
-- 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
This and the rest is discussed in my draft for the docs changes, which
can be found at:
http://www.humbedooh.com/apache/mod_lua.html.en#databases
I hope you guys will review it and let me know if you think it's time to
actually commit the code ;)
With regards,
Daniel.