On 02/16/2016 11:34 AM, Daniel W. Graham wrote:
Is there a good way to perform database insert using
version 4.0?
You mean to do so asynchronously? Or just insert? If the latter,
sql_query(). :-)
If the former, try:
loadmodule "rtimer"
loadmodule "mqueue"
modparam("rtimer", "timer",
"name=insert_writer;interval=10u;mode=1")
modparam("rtimer", "exec",
"timer=insert_writer;route=DO_INSERT")
modparam("mqueue", "mqueue", "name=insert_queue")
route {
...
mq_add("insert_queue", "insert_stmt",
"INSERT INTO tbl (col1, col2, ... colN) VALUES (val1, ... valN)");
}
route[DO_INSERT] {
while(mq_fetch("insert_queue") {
$var(stmt) = $mqv(insert_queue);
sql_query("handle", "$var(stmt)", "res");
sql_result_free("res");
mq_pv_free("insert_queue");
}
}
-- Alex
--
Alex Balashov | Principal | Evariste Systems LLC
303 Perimeter Center North, Suite 300
Atlanta, GA 30346
United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)
Web:
http://www.evaristesys.com/,
http://www.csrpswitch.com/