Re: PHP PDO comment on IRC

From: Date: Wed, 15 Apr 2009 21:07:17 +0000
Subject: Re: PHP PDO comment on IRC
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-43715@lists.php.net to get a copy of this message
Matteo Beccati wrote:
Here's a proposal: http://www.beccati.com/misc/php/pdo_streams_v4.diff The idea is to add a new #define PDO_DRIVER_API_CHECK which is verified at compile time by the C preprocessor. If its value doesn't match the main PDO_DRIVER_API an #error is triggered, e.g: In file included from /tmp/PDO_PGSQL-1.0.2/pdo_pgsql.c:29: /usr/local/include/php/ext/pdo/php_pdo_driver.h:50:2: error: #error "PDO driver not compatible with the PDO API version in use"
Hi Matteo, I'll just comment on the internal API versioning part - let's get that sorted out first. To make it easier to write database specific PDO drivers that work with a range of versions of the internal PDO API, I think PDO_DRIVER_API_CHECK could be changed to be min & max values that the driver supports. The check would be: #if !defined(PDO_DRIVER_API_IMPLEMENTED_MIN) || \
    !defined(PDO_DRIVER_API_IMPLEMENTED_MAX) || \
    !(PDO_DRIVER_API_IMPLEMENTED_MIN <= PDO_DRIVER_API && \
      PDO_DRIVER_API <= PDO_DRIVER_API_IMPLEMENTED_MAX)
#error "PDO driver not compatible with the PDO API version in use" #endif Adding code documentation to the macros explaining what driver writers can & should do would be useful (i.e. please add some). I'm not keen on the introduction of php_pdo_version.h. It seems a kludge so that PDO passes its own version check. It makes PDO itself defines the same value in two places. If you're going to bump PDO_DRIVER_API and change the API, thus making all current PDO drivers incompatible, you may as well continue making changes. Perhaps put the version check code in a new file that is only included in DB driver files, and not in PDO .c files. Chris -- Email: christopher.jones@oracle.com Twitter: http://twitter.com/ghrd Free PHP Book: http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf

« previous php.internals (#43715) next »