Re: [Cppcms-users] Cppcms-users] cppdb: test connect to database and reconnection
Brought to you by:
artyom-beilis
From: Daniel V. <chi...@gm...> - 2010-12-29 15:33:06
|
On Tue, 2010-12-28 at 23:50 -0800, Artyom wrote: > When connection is closed all prepared statements are destroyed. > They would be prepared upon first request automatically. > > Of course you should **not** keep them on your own, i.e.: > > class foo { > foo() > { > sql("mysql:..."); > my_insert = sql.prepare("INSERT ..."); > } > void insert() { > my_insert.bind(...); > my_insert.exec() > } > session sql; > statement my_insert; > } > > But rather access them as usually, > > class foo { > foo() > { > conn_str = "mysql:...;@pool_size=5" > } > void insert() { > session sql(conn_str); > sql << "INSERT ..." << x << exec; > } > std::string conn_str; > } > My problem was that I kept them on my own!. Thank you! I see into your code, and I figure out you not rebuild prepared statements, instead you fetch them from cache. I think this information is useful for new users to guide them on how to use the library. |