note 108481 added to pdo.prepare
| From: | orrd101 at gmail dot com | Date: | Mon, 30 Apr 2012 00:46:38 +0000 |
| Subject: | note 108481 added to pdo.prepare | ||
| Groups: | php.notes php.notes | ||
| Request: | Send a blank email to php-notes+get-187403@lists.php.net to get a copy of this message | ||
Don't just automatically use prepare() for all of your queries.
If you are only submitting one query, using PDO::query() with PDO::quote() is much faster (about 3x
faster in my test results with MySQL). A prepared query is only faster if you are submitting
thousands of identical queries at once (with different data).
If you Google for performance comparisons you will find that this is generally consistently the
case, or you can write some code and do your own comparison for your particular configuration and
query scenario. But generally PDO::query() will always be faster except when submitting a large
number of identical queries. Prepared queries do have the advantage of escaping the data for you,
so you have to be sure to use quote() when using query().
----
Server IP: 69.147.83.197
Probable Submitter: 99.88.245.232
----
Manual Page -- http://www.php.net/manual/en/pdo.prepare.php
Edit -- https://master.php.net/note/edit/108481
Del: integrated -- https://master.php.net/note/delete/108481/integrated
Del: useless -- https://master.php.net/note/delete/108481/useless
Del: bad code -- https://master.php.net/note/delete/108481/bad+code
Del: spam -- https://master.php.net/note/delete/108481/spam
Del: non-english -- https://master.php.net/note/delete/108481/non-english
Del: in docs -- https://master.php.net/note/delete/108481/in+docs
Del: other reasons-- https://master.php.net/note/delete/108481
Reject -- https://master.php.net/note/reject/108481
Search -- https://master.php.net/manage/user-notes.php