Re: [PDO] Fixing bug #44639 for mysql
[email protected] (Oskar Eisemuth) Wed, 28 Oct 2009 15:02:11 +0100
| Newsgroups | php.pdo |
|---|---|
| Message-ID | <[email protected]> |
Hello goran miskovic wrote: > As user, I would expect, no meter what, that if a variable type is > explicitly given that it must be handled in that way. > > If I am saying that variable type is integer and I am passing string then > perhaps variable might be converted to integer. However, I would prefer > throwing exception and letting me know that I did something wrong: > "Exception: Declared variable type INTEGER, passed variable type FLOAT (or > whatever)". > My original idea was to throw an Exception too, but I thought it would break PDO to much. An E_NOTICE could be send, or PDO gets a strict type checking mode? I don't think the php internals know if a string can be converted fully or partial to an integer. Anyway an valid integer value in a string shouldn't be rejected, it somehow feels wrong for PHP throwing Exceptions or Errors for "0" suddenly, as PDO mostly thinks anything is a string and returns strings, it should accept the values it produces. :-) > Let's say that I am explicitly saying PDO::PARAM_INT and I am passing string > with date. In such case, most likely, date string would be converted to 1 or > 0, creating unexpected results and a bug that would be extremely hard to > spot. > Well I think currently PHP isn't the right language for that, you have to wait for Lukas type checking rfc. It would be nice to have something like a PDO type checking table, but I wouldn't say this is something for a bug fix and needs a good design. PDO2 todolist where are you? > We, users (PHP developers) should know what we are doing and if we are > making mistakes, we should be warned instead of guessing our intentions. > If the programmer atleast know the guess result and the result is the same on all drivers, this would be much better. Well and if you try to put your date variable currently into PARAM_INT it would work, but this is fundamental wrong!. If you don't specific it, it will be a PARAM_STR and all is fine. Best regards Oskar Eisemuth