in reply to dbi: prepare vs prepare_cached -- which is best ?
Prepare will send the SQL query to the database server, which will compile it, to check if the SQL query syntax is right or not. If it is not right, then the reason can be get from the $dbh->errstr.
which is best, prepare or prepare_cached ? And in which case which is bestIt depends
For example, I am having a function which will select a row from a table, depending upon the argument passed to that function.
So If I use the prepare, it will give the query to the database server to compile it and then it will return the handle. If the function is called in a loop, then it will be in-efficient.
In those case we can use prepare_cached, because we are using the same query and no need to compile it again.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dbi: prepare vs prepare_cached -- which is best ?
by mje (Curate) on Dec 18, 2008 at 15:02 UTC | |
by lakshmananindia (Chaplain) on Dec 19, 2008 at 03:31 UTC | |
by mje (Curate) on Dec 19, 2008 at 13:24 UTC |