Re: [PDO] Mapping data type/size

[email protected] (Lukas Kahwe Smith) Wed, 28 Oct 2009 19:41:12 +0100
Newsgroups php.pdo
Message-ID <[email protected]>
On 28.10.2009, at 18:15, Lester Caine wrote:

> Please bare with me ... I'm still trying to 'convert' from my normal  
> way of working ;)
>
> PDO::PARAM_INT is available, but no other numeric formats?
>
> I've been working through all the options to map data types into the  
> correct internal format, but I'm not having much luck. Numeric types  
> would be better passed as numbers rather than strings, but the main  
> problem I'm hitting here is how to know which field types from one  
> database map to another. Such as 'BOOL' which is normally handled as  
> a CHAR(1) in Firebird, and also the different numeric field sizes of  
> FLOAT and the like. The bottom line is that we have to know the  
> structure of the table before we can use it? We can't simply ask for  
> those details from the database and adjust things acordingly?

Well bool is one of those examples that is hard to do, since many  
developers do it differently and most RDBMS do not support it  
natively. So some do BIT, others TINYINT, yet others CHAR(1) and some  
have a native type.

> Should it be possible to force LOB fields to be connected as  
> PDO::PARAM_STR? I'm not sure that this actually solves the problem  
> since there is needs to be some information available to tell you  
> which fields are LOB but need mapping to simple strings? However  
> 'insert' should just load a string into the bound field? So it's  
> just query that needs to return a string later? With Firebird we  
> simply switch the driver to IBASE_TEXT mode and it returns strings.  
> Should I be looking to add that to the pdo_firebird driver as an  
> optional setting. Really until I can get this bit working I can't  
> get much further using my current projects.

Well there could be a special LOB type that means dump straight to a  
string.
As for this option, there are a few driver specific options already  
(take the buffered query option for mysql). We have not really defined  
yet how to approach stuff like this, especially the second it is also  
relevant for another driver.

> I regularly use date/time internally in Firebird as the numeric  
> values that they are handled as but this is another area that is  
> getting lost in the translation between PDO and the database.  
> Although this may just be a matter of getting the right format of  
> string conversion - I've had great fun with US/UK day/month ordering  
> over the years :(


Well different date formats is nightmarish enough that its really  
beyond the scope of what we can hope for with PDO. In MDB2 (and  
probably most other true abstraction layers) you just support ISO date  
formats and thats it.

regards,
Lukas Kahwe Smith
[email protected]