There is no hard and fast rule about just how well the prepare, execute, execute ... and the do variations will work. Generally speaking the $dbh->do( ... ) will create and destroy a new statement handle for each use. Using the $dbh->prepare( .. ) will almost inevitably result in better performance, particularly on databases which do actually cache the statement. Sadly, I don't think mysql does. At least prior to MySQL 4.1.3 it did not cache prepared statements, more recently you can enable the caching of prepares by enabling the mysql_server_prepare option. This is a connection option and is detailed in the latest DBD::mysql documentation ( 3.0006 as I write this ). That being said, their is also the issue of placeholders you raised, DBD::mysql emaulates placeholders because I understand they are not directly supported by the MySQL API. In carefully crafted code there can be an advantage with MySQL, but not as great as with Oracle, for example.
In reply to Re: DBI do vs prepare
by jdtoronto
in thread DBI do vs prepare
by BrianC
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |