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.
In reply to Re: dbi: prepare vs prepare_cached -- which is best ?
by lakshmananindia
in thread dbi: prepare vs prepare_cached -- which is best ?
by sathiya.sw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |