List:MySQL++« Previous MessageNext Message »
From:Adam Nielsen Date:February 1 2010 2:16am
Subject:Re: How to do a large template query?
View as plain text  
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.
Thread
How to do a large template query?Adam Nielsen27 Jan
  • Re: How to do a large template query?Warren Young27 Jan
    • Re: How to do a large template query?Adam Nielsen28 Jan
      • Re: How to do a large template query?Joel Fielder28 Jan
        • Re: How to do a large template query?Warren Young28 Jan
          • Re: How to do a large template query?Adam Nielsen29 Jan
            • Re: How to do a large template query?Joel Fielder29 Jan
              • Re: How to do a large template query?Joel Fielder29 Jan
              • Re: How to do a large template query?Adam Nielsen1 Feb
            • Re: How to do a large template query?Warren Young29 Jan
              • Re: How to do a large template query?Adam Nielsen1 Feb
                • Re: How to do a large template query?Warren Young1 Feb
                  • Re: How to do a large template query?Warren Young7 Feb
          • Re: How to do a large template query?Warren Young7 Feb