Re: [PDO] PDO docs and spec problem

[email protected] (Oskar Eisemuth) Mon, 02 Nov 2009 15:34:27 +0100
Newsgroups php.pdo
Message-ID <[email protected]>
Lester Caine wrote:
> Hannes Magnusson wrote:
>>>> In general we have said we do not really want to use the wiki to 
>>>> document
>>>> things, even for temporary use .. because temporary becomes permanent.
>>>> However we can use it to at least keep a todo list of things that 
>>>> still need
>>>> to be documented.
>>> We can use it until a given doc is good enough to be pushed the
>>> documentation. And the wiki is obviously the right place for
>>> specs&related documents.
>>
>> Just in case you guys dont know about it, but current PDO is actually
>> documented:
>> http://php.net/manual/en/internals2.pdo.php
>
> There are a few problems with that section, apart from it being a 
> little out of date in places.
>
> But the main thing that seems to be missing is a 'framework' of what 
> functionality is expected in general, and perhaps it would be useful 
> to have a comparison table between databases that shows what parts do 
> match and what don't.
>
> And more important, what one has to do outside PDO to make things more 
> compatible inside?
>
The really most annoying problem is the difference in parameter binding 
and the lack of proper documented behavior how these stuff should work. 
If there would be a  documented way I think the  "[PDO] Fixing bug 
#44639 for mysql" thread would be much smaller and someone had pointed 
to the documented way to work with parameters. It's ok that people 
disagree on the specs how binding parameters should work and fix them, 
allowing every driver developer to find the best way that seems to fit 
is the wrong approach.

http://php.net/manual/en/internals2.pdo.php
 
It really only shows the base interaction between PDO and PDO Driver, 
not really how a driver should work with the data, maybe I am wrong, but 
I do think the mysql driver would do proper binding when PDOs 
documentation would clearly say use the PARAM_TYPE and create an 
Exception when the data doesn't fit, or PDO enforces the right type 
already, and told us in the internal documentation that it does. If 
something doesn't work, there could be a change in the PDO specs so a 
bug can be fixed and driver code wouldn't try to use workarounds to find 
a way out from the dark corners. Currently there is simply to much guess 
work and "fix until it works"-code between PDO and it's drivers...

Anyway, I tried to start to document the current binding internals at 
the brainstorm wiki page (by simply checking the statement source files) 
So far each driver likes to do it's own way and common answers need to 
be find:

What if a parameter is null?
If it's an empty string, can it be null for non character fields?
Should PDO enforce types at bind and then let the driver decide?

Best regards
Oskar Eisemuth