diff options
author | Lars Westermann <lwe@php.net> | 2007-10-30 16:30:40 +0000 |
---|---|---|
committer | Lars Westermann <lwe@php.net> | 2007-10-30 16:30:40 +0000 |
commit | 9d2b9dd20e5ec14719ae5e7972a13224d7c01224 (patch) | |
tree | bd3284f1dbea4f008ceecf2aa69a293b7b5e922c | |
parent | aa6c5a81f9925ead13ec8b06683f31a1069639b1 (diff) | |
download | php-git-9d2b9dd20e5ec14719ae5e7972a13224d7c01224.tar.gz |
- Added 3 firebird specific attributes to firebird_handle_set_attribute()
- function. They control formatting of date/timestamp columns.
- pdo_firebird_handle_factory() now throwing an execption if unable to attach
- database (bug reports 39822 and 41522)
- Fixed bug #39822 (new PDO() doesn't work with firebird)
- Fixed bug #41522 (PDO firebird driver returns null if it fails to connect)
-rw-r--r-- | ext/pdo_firebird/firebird_driver.c | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index 6a6bc09696..3083d0795d 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -114,6 +114,16 @@ static int firebird_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */ RECORD_ERROR(dbh); } + if (H->date_format) { + efree(H->date_format); + } + if (H->time_format) { + efree(H->time_format); + } + if (H->timestamp_format) { + efree(H->timestamp_format); + } + pefree(H, dbh->is_persistent); return 0; @@ -482,6 +492,30 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS dbh->auto_commit = Z_BVAL_P(val); } return 1; + + case PDO_FB_ATTR_DATE_FORMAT: + convert_to_string(val); + if (H->date_format) { + efree(H->date_format); + } + spprintf(&H->date_format, 0, "%s", Z_STRVAL_P(val)); + return 1; + + case PDO_FB_ATTR_TIME_FORMAT: + convert_to_string(val); + if (H->time_format) { + efree(H->time_format); + } + spprintf(&H->time_format, 0, "%s", Z_STRVAL_P(val)); + return 1; + + case PDO_FB_ATTR_TIMESTAMP_FORMAT: + convert_to_string(val); + if (H->timestamp_format) { + efree(H->timestamp_format); + } + spprintf(&H->timestamp_format, 0, "%s", Z_STRVAL_P(val)); + return 1; } return 0; } @@ -500,7 +534,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */ /* }}} */ /* called by PDO to get a driver-specific dbh attribute */ -static int firebird_handle_get_attribute(pdo_dbh_t const *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */ +static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */ { pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; @@ -615,7 +649,7 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM char dpb_buffer[256] = { isc_dpb_version1 }, *dpb; dpb = dpb_buffer + 1; - + /* loop through all the provided arguments and set dpb fields accordingly */ for (i = 0; i < sizeof(dpb_flags); ++i) { if (dpb_values[i] && buf_len > 0) { @@ -627,15 +661,14 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM } /* fire it up baby! */ - if (isc_attach_database(H->isc_status, 0, vars[0].optval, &H->db,(short)(dpb-dpb_buffer), - dpb_buffer)) { + if (isc_attach_database(H->isc_status, 0, vars[0].optval, &H->db,(short)(dpb-dpb_buffer), dpb_buffer)) { break; } dbh->methods = &firebird_methods; dbh->native_case = PDO_CASE_UPPER; dbh->alloc_own_columns = 1; - + ret = 1; } while (0); @@ -646,6 +679,14 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM } } + if (!dbh->methods) { + char errmsg[512]; + ISC_STATUS *s = H->isc_status; + isc_interprete(errmsg, &s); + zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s", + "HY000", H->isc_status[1], errmsg); + } + if (!ret) { firebird_handle_closer(dbh TSRMLS_CC); } @@ -654,6 +695,7 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM } /* }}} */ + pdo_driver_t pdo_firebird_driver = { /* {{{ */ PDO_DRIVER_HEADER(firebird), pdo_firebird_handle_factory |