PHP Classes

PDO

Recommend this page to a friend!

      PHP Classes blog  >  PHP 5.7 New Features ...  >  All threads  >  PDO  >  (Un) Subscribe thread alerts  
Subject:PDO
Summary:Incorrect affirmation!
Messages:2
Author:Michel Chouinard
Date:2014-09-23 00:08:30
Update:2014-09-23 04:37:41
 

  1. PDO   Reply   Report abuse  
Picture of Michel Chouinard Michel Chouinard - 2014-09-23 02:05:43
Just to set the context:

---------------------------------------
Arturs Sosins: Like PDO.

Manuel Lemos: No, PDO, it emulates everything. Don't use PDO. For this purpose, PDO is not a good idea because it emulates the prepared statements. So it will do the same. It will paste the file contents in the query.
---------------------------------------

Please, read the manual before posting such affirmation:

As stated in php PDO_MYSQL driver documentation:

php.net/manual/en/ref.pdo-mysql.php

"PDO_MYSQL will take advantage of native prepared statement support present in MySQL 4.1 and higher. If you're using an older version of the mysql client libraries, PDO will emulate them for you."

So if the installed MySql library support it it will use it. Try a PDO::setAttribute(PDO::ATTR_EMULATE_PREPARES, false); and test it. Sure, would be nice if the driver didn't fallback if forced and triggered an error instead.

As for trying to store a 2g file in a DB, it's surely not a good idea but a LONGBLOB could do the trick. The only obstacle could be the memory limit of PHP and/or MySQL.

  2. Re: PDO   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-09-23 04:37:41 - In reply to message 1 from Michel Chouinard
It is good to know that it works in more recent versions.

I wonder what that means in practice because PDO emulated prepared statements are different from real prepared statements in several ways. For instance, native prepared statements use ? as place holder, not :name syntax. If you use ?, fallback to emulated prepared queries will not work.