Re: [PDO] PDO_DBLIB Native PHP Type binding

[email protected] (Wez Furlong) Wed, 3 Nov 2010 23:25:30 -0400
Newsgroups php.internals,php.pdo
Message-ID <[email protected]>
On Nov 3, 2010, at 9:52 PM, Stanley Sufficool wrote:

> Before I gut PDO_DBLIB one more time to implement native parameter
> binding for stored procedures, what are the thoughts on returning the
> column values from the database as the native PHP type when possible?
> Currently everything is returned as a string, incurring overhead for
> conversion

The design philosophy was to pull the data out as strings as this  
gives the highest data fidelity (especially with the various numeric  
types) and is a pragmatic choice for the majority of web apps which  
are largely in text land anyway, and typically are not bottlenecked on  
the performance of converting database column values.

Some drivers, particularly postgres, are unable to request string data  
and therefore return their results in the type that most closely  
matches the C datatype forced on it by the API.

This has been a source of complaints from some about the consistency  
of the returned data for apps that are designed to run against  
multiple database backends.

I would advise against changing the behavior of the driver if  
possible, and against changing it away from the established  
stringiness of PDO without good reason.

> and creating problems hinting at the desired binding type
> for BLOBS and numeric data types.

Can you elaborate on this? You can explicitly set the desired binding  
via bindColumn.

--Wez.