Re: [PDO] Mapping data type/size
[email protected] (goran miskovic) Thu, 29 Oct 2009 17:59:44 +0100
| Newsgroups | php.pdo |
|---|---|
| Message-ID | <[email protected]> |
I am using PDO:: PARAM_BOOL although in mySQL it would be 0 or 1 and it makes sense to me: Boolean is variable type defined in PHP and as a developer I don't care much if there is matching field type in the database or not. For sure somehow it must be handled. I would expect PDO to know in which way particular database is handling boolean values and send correct value. My understanding is that when explicitly defining variable type I am saying that given variable is of defined PHP type and it is on PDO to handle it accordingly to RDBMS in use. Goran On Thu, Oct 29, 2009 at 4:41 PM, Lukas Kahwe Smith <[email protected]>wrote: > > On 29.10.2009, at 16:34, Lester Caine <[email protected]> wrote: > > Lukas Kahwe Smith wrote: >> >>> On 28.10.2009, at 19:41, Lukas Kahwe Smith wrote: >>> >>>> >>>> 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. >>>> >>> oh just learned there is a PDO::PARAM_BOOL >>> http://php.net/manual/en/pdo.constants.php >>> >> >> BUT - what use is that when there is no matching field type in the >> database? That was one of the problems I was trying to say but messing it up >> ;) >> > > yeah. its impossible. either pdo would have to define a standard or it > would have to be a config setting. not sure what this parameter even does > atm. > > regards > lukas > > > -- > PDO Working Group Mailing List (http://pdo.php.net) > To unsubscribe, visit: http://www.php.net/unsub.php > >