Re: [Cppcms-users] Bizarre prepared statement problem
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2012-05-22 16:59:02
|
> cppdb::result Base::get_all_items(...)
> {
>
> cppdb::result r;
> string ts = "2012-05-17 23:59:59";
> ...
> r=sql ....
> << date_limited_only
> << ts
> << ts
> << ts
> << aircraft_id;
>
> return r; // <----
> }
>
And than in some other place
r = get_all_times(...)
while(r.next())
...
In the first request of r.next() the query is actually
executed, when **ts** goes out of the scope and becomes invalid.
and during query the ts is not valid.
That is why it does not work.
I can suggest switch to:
get_all_times
{
r = sql ....
r.next();
return r;
}
r=get_all_times();
while(!r.empty()) {
r >> ...
r.next()
}
Artyom Beilis
|