Lester Caine wrote:
Following on ....
Lukas Kahwe Smith wrote:
Lester Caine wrote:
The main thing I see there is 'raw' SQL. Loading the variables
directly into the script, rather than simply binding them as params.
I have yet to work out a way of converting some of my dynamically
generated SQL into a format that will work with PDO - on any
database. I've only ever used ADOdb and that handles ALL of the
parameterizing of things transparently.
I have no clue what type of dynamically generated SQL you are talking
about. Are you talking about being able to dynamically stick
identifiers into placeholders? This is simply not possible if you are
using native prepared statements. If you emulate them, yes you can,
but then you can might as well use sprintf() with quote() (maybe with
a wrapper).
OK this is a key difference between MySQL and other databases - at least
looking at the raw drivers. Firebird ( and PostgreSQL ) can use
parameters to handle the transfer of values to the query.
From pg_query_params manual - "The primary advantage of
pg_query_params() over pg_query() is that parameter values may be
separated from the query string, thus avoiding the need for tedious and
error-prone quoting and escaping."
But these parameters may only be literals not identifiers. The only
difference in placeholder support is if the placeholders are named
(pgsql, oracle etc.) or not (db2, mysql etc.). PDO (and MDB2, Doctrine
etc. for that matter) support both the named and unnamed in all drivers.
SELECT * FROM ?; // does not work
The reason is technical, the idea behind prepared statements is to have
the database be able to parse and plan the query once. Without
identifiers this would not be possible.
PDO does wrap this quite nicely, except that BLOB's can only be passed
as raw content? The ability to just pass a BLOB ID means that you only
access that part of a large blob that you need. And most database
engines would benefit from being able to handle BLOB elements
independent of the general fetch. Rather than duplicating and processing
several hundred 'k' text blobs, you just pass the link to the original?
Blobs in PDO are implemented via the stream API, so its not only "raw
content". Adding support for blob id's would be a good idea if its not
yet supported.
Speaking of which, another area where PDO standards to reduce duplicate
efforts is documentation, which is still a bit lacking atm (where is the
new Dan?).
regards,
Lukas
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php