Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Problem with DBI and MySQL

by ait (Friar)
on Aug 23, 2010 at 01:29 UTC ( #856622=note: print w/ replies, xml ) Need Help??

in reply to Re: Problem with DBI and MySQL
in thread Problem with DBI and MySQL

If the values you are inserting are in the column order, you dont need the column enumeration at all - you can just do

That is not a good idea because it makes the insert very fragile to possible database changes: if the field order changes your insert breaks. It is always wise to use explicit columns and then the values.

Regarding your recommendation to use placeholders (aka bind variables) you are absolutely correct. If your database supports it, DBI will take advantage and prepare the statements in the database, which can boost your transaction speed in great orders of magnitude depending on the underlying RDBMS.

The use of do() should be avoided at all times, and every statement should be prepared using bind variables. Of course There's More Than One Way To Do It, but in general terms, it makes a lot of sense to prepare your queries beforehand, much like you would in database procedure languages such a PL/pgSQL and Oracle's PL/SQL

Comment on Re^2: Problem with DBI and MySQL

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://856622]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2015-11-25 15:22 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (681 votes), past polls