List:MySQL and Perl« Previous MessageNext Message »
From:Jochen Wiedmann Date:July 26 2001 6:42am
Subject:Re: quoting
View as plain text  
Christopher Hicks wrote:

> On Tue, 24 Jul 2001, Dodger wrote:
>>>(btw, I don't want to use placeholders)
>>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This is silly.
>>Do you have a good reason why not?
> (A) When you don't know exactly which fields are going to be available for
> the insert/update.

I do not understand this argument. In particular for dynamically
generated statements placeholders are very elegant. I typically
create an array @col_names and an array @col_values:

   my $stmt = "INSERT INTO table (" .
     join(", ", @col_names) . ") VALUES (" .
     join(", ", map{ "?" } @col_values) . ")";
   $sth = $dbh->do($stmt, undef, @col_values);

Try to make this shorter, cleaner, more failsafe or faster
with quote!

> (B) Preparing is usually more trouble than it's worth since it doesn't
> provide any performance improvement for MySQL anyway.  For DB2 et al where
> the SQL parsing overhead is ridiculous it's a necessity.

I never had trouble with placeholders, but many trouble with

not using it. Besides, even with MySQL the performance is
better with placeholders than without.

quotingRaul Dias24 Jul
  • Re: quotingDodger24 Jul
    • Re: quotingChristopher Hicks25 Jul
      • Re: quotingJochen Wiedmann26 Jul
Re: quotingRaul Dias27 Jul
  • Re: quotingDodger27 Jul
  • Re: quotingJochen Wiedmann27 Jul
Re: quotingRaul Dias27 Jul
  • Re: quotingJochen Wiedmann27 Jul
  • Re: quotingDodger27 Jul