[ale] brain damaged perl DBI

James P. Kinney III jkinney at localnetsolutions.com
Fri Jan 28 14:43:20 EST 2005


On Fri, 2005-01-28 at 13:34 -0500, fletch at phydeaux.org wrote:

> 
> The better solution would be to use a placeholder.  Then you can prepare the
> statement once outside the foreach and pass the id when you execute it (and
> you're also less vulnerable to SQL injection attacks).
> 
> my $sth = $dbh->prepare( qq{
> SELECT id FROM assembly WHERE parts_id = ?
> });
> foreach my $id ( @clone_list ) {
>   $sth->execute( $id ) or $form->dberror( "assembly SELECT id $id" );
> 
>   while( my $row = $sth->fetchrow_arrayref ) {
>     #...
>   }
> 
>   $sth->finish( );
> }
> 
> 
Great idea! 

> See perldoc DBI for more info on placeholders.  Also check out the trace()
> method
> which can be handy to see exactly what you're sending back and forth to
> your DB
> backend.

Digging for info on trace(). Thanks for the info. 
> 
-- 
James P. Kinney III          \Changing the mobile computing world/
CEO & Director of Engineering \          one Linux user         /
Local Net Solutions,LLC        \           at a time.          /
770-493-8244                    \.___________________________./
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part




More information about the Ale mailing list