Hi Joel,
> It looks like you're stuck with having to hand roll the SQL. mysql++
> can soften the blow though - you can pass a functor to Query::for_each
> (or store_if) to handle SELECT into an object. Define a constructor
> that takes a mysqlpp::Row& for your object. Something like what follows
> at the bottom of this mail. Note you don't even need to store the
> records, you could just process them in the functor.
>
> For INSERT I guess you'll just have to add an insert function to the
> Book object and write the INSERT statement yourself.
>
> Good luck!
Interesting idea, I hadn't thought of doing it this way. The only
drawback (from my point of view) is that you have to create an SQL
statement by hand. Wherever possible I always like to avoid escaping
user input and mixing it in with some command, as I'm paranoid the
escaping mechanism will fail one day and someone will be able to break
out of it.
If there's a way of passing parameters separately to the command (SQL
statement), I would prefer that every time.
Having said that, I learnt something from reading your example so thanks
for posting :-)
Cheers,
Adam.