LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Perl / MySQL oddity

[ILUG] Perl / MySQL oddity

Niall niall at magicgoeshere.com
Tue Apr 25 17:01:13 IST 2000


On Tue, Apr 25, 2000 at 03:31:22PM +0100, Nick Hilliard wrote:

> > > $sth = $dbh->prepare("INSERT INTO $table $Fields VALUES (?,?,?,?,?,?,?)");
> > > $sth->execute(	$Description, substr($Description, 0, 50),
> > > 		$2, $Keywords, $UnixPath, $MacPath, $Volume);
> > 
> > I tried using this syntax at some stage but had some kind of problem with it
> > and didn't keep trying. However, 
> 
> Really?  What sort of problems did you have?

Well, I'd never used this syntax until the other day and then I read in Jay
Flaherty's "MySQL Perl DBI/DBD Manual Version 0.4" the following code snippet

my @names = ['Flaherty', 'Jones', 'Smith']; 
$dbh->{RaiseError} = 1; 
my $sth = $dbh->prepare("UPDATE contact SET phone = '555-1212'
WHERE last_name = ?");
$sth->execute(@names); 


Now as this appeared to do something which I needed to do at the time, I
assumed that it would do what I wanted i.e prepare a statement and execute
it for each element of @names. I haven't checked, but I now gather that
that's a mis-interpretation on my behalf, but in mitigation I was lead
astray by the snippet above, where presumably instead of 

$sth->execute(@names);

there should have been

for (@names) { $sth->execute($_) }

> Your problem is curious though.  

It is. Esp. given Thomas' latest information that the problem doesn't occur
with $1

> I've looked at the XS code for quote() and execute() but rapidly got lost 

You can sing that :-)

in there 

> (must dig out my perl internals book one of these days).

Book nothing - I'm not going back there without a H & K and a Kevlar vest. :-)



Regards,


Niall






More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell