Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://856622]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2018-03-19 02:17 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.