[Cppcms-users] statement::bind can be deceptive/dangerous
Brought to you by:
artyom-beilis
From: <ele...@ex...> - 2012-05-07 06:28:05
|
I was trying to figure out why st.prepare(....) .... st.bind(5, r.get<string>("date_action")); .... st.exec() in my code produces unpredictable behaviour untill I read in the documentation that - Note: the reference to the string MUST remain valid until the statement is queried or executed! In my code im copying some old rows into new rows and r.get<string>("date_action") returns the letter "R" but after it got binded to the new statement it was showing "l" which puzzled me to no-end as to why, but if I did string wtf = r.get<string>("date_action"); st.bind(5, wtf); it worked fine. Should statement::bind be using value instead of reference semantics? Petr |