summaryrefslogtreecommitdiff
path: root/ext/pdo_firebird
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 19:39:21 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 19:39:21 -0400
commit6821b67124604da690c5e9276d5370d679c63ac8 (patch)
treebefb4ca2520eb577950cef6cb76d10b914cbf67a /ext/pdo_firebird
parentcd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (diff)
downloadphp-6821b67124604da690c5e9276d5370d679c63ac8.tar.gz
Imported Upstream version 5.3.0RC1upstream/5.3.0_RC1upstream/5.3.0RC1
Diffstat (limited to 'ext/pdo_firebird')
-rw-r--r--ext/pdo_firebird/config.m411
-rw-r--r--ext/pdo_firebird/firebird_driver.c115
-rw-r--r--ext/pdo_firebird/firebird_statement.c187
-rw-r--r--ext/pdo_firebird/pdo_firebird.c8
-rw-r--r--ext/pdo_firebird/php_pdo_firebird.h14
-rw-r--r--ext/pdo_firebird/php_pdo_firebird_int.h27
-rw-r--r--ext/pdo_firebird/tests/ddl.phpt2
-rw-r--r--ext/pdo_firebird/tests/execute.phpt2
8 files changed, 192 insertions, 174 deletions
diff --git a/ext/pdo_firebird/config.m4 b/ext/pdo_firebird/config.m4
index 4182931bf..b99ee46ef 100644
--- a/ext/pdo_firebird/config.m4
+++ b/ext/pdo_firebird/config.m4
@@ -1,14 +1,17 @@
dnl
-dnl $Id: config.m4,v 1.8.4.2 2007/07/31 13:02:00 jani Exp $
+dnl $Id: config.m4,v 1.8.4.2.2.1 2008/07/25 13:46:23 jani Exp $
dnl
-if test "$PHP_PDO" != "no"; then
-
PHP_ARG_WITH(pdo-firebird,for Firebird support for PDO,
[ --with-pdo-firebird[=DIR] PDO: Firebird support. DIR is the Firebird base
install directory [/opt/firebird]])
if test "$PHP_PDO_FIREBIRD" != "no"; then
+
+ if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
+ AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
+ fi
+
if test "$PHP_PDO_FIREBIRD" = "yes"; then
FIREBIRD_INCDIR=/opt/firebird/include
FIREBIRD_LIBDIR=/opt/firebird/lib
@@ -49,5 +52,3 @@ if test "$PHP_PDO_FIREBIRD" != "no"; then
PHP_SUBST(PDO_FIREBIRD_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(pdo_firebird, pdo)
fi
-
-fi
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index 954b2a0c9..1d826571a 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: firebird_driver.c,v 1.17.2.2.2.6 2008/12/31 11:17:41 sebastian Exp $ */
+/* $Id: firebird_driver.c,v 1.17.2.2.2.4.2.6 2009/02/15 21:51:00 felipe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -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;
@@ -264,38 +274,38 @@ static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unqu
char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC)
{
int qcount = 0;
- char const *c;
+ char const *co, *l, *r;
+ char *c;
+ if (!unquotedlen) {
+ *quotedlen = 2;
+ *quoted = emalloc(*quotedlen+1);
+ strcpy(*quoted, "''");
+ return 1;
+ }
+
/* Firebird only requires single quotes to be doubled if string lengths are used */
-
/* count the number of ' characters */
- for (c = unquoted; (c = strchr(c,'\'')); qcount++, c++);
+ for (co = unquoted; (co = strchr(co,'\'')); qcount++, co++);
- if (!qcount) {
- return 0;
- } else {
- char const *l, *r;
- char *c;
-
- *quotedlen = unquotedlen + qcount;
- *quoted = c = emalloc(*quotedlen+1);
-
- /* foreach (chunk that ends in a quote) */
- for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
-
- /* copy the chunk */
- strncpy(c, l, r-l);
- c += (r-l);
-
- /* add the second quote */
- *c++ = '\'';
- }
-
- /* copy the remainder */
- strncpy(c, l, *quotedlen-(c-*quoted));
+ *quotedlen = unquotedlen + qcount + 2;
+ *quoted = c = emalloc(*quotedlen+1);
+ *c++ = '\'';
+
+ /* foreach (chunk that ends in a quote) */
+ for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
+ strncpy(c, l, r-l+1);
+ c += (r-l+1);
+ /* add the second quote */
+ *c++ = '\'';
+ }
- return 1;
- }
+ /* copy the remainder */
+ strncpy(c, l, *quotedlen-(c-*quoted)-1);
+ (*quoted)[*quotedlen-1] = '\'';
+ (*quoted)[*quotedlen] = '\0';
+
+ return 1;
}
/* }}} */
@@ -482,6 +492,35 @@ 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_ATTR_FETCH_TABLE_NAMES:
+ convert_to_boolean(val);
+ H->fetch_table_names = 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 +539,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;
@@ -569,7 +608,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
strcpy(&buf[i++], " ");
}
add_next_index_string(info, buf, 1);
- } else {
+ } else if (H->last_app_error) {
add_next_index_long(info, -999);
add_next_index_string(info, const_cast(H->last_app_error),1);
}
@@ -615,7 +654,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 +666,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 +684,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 +700,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
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index aa1b35c00..16ff7ca30 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: firebird_statement.c,v 1.18.2.1.2.8 2009/02/09 12:07:35 felipe Exp $ */
+/* $Id: firebird_statement.c,v 1.18.2.1.2.5.2.11 2009/02/09 12:07:23 felipe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -92,18 +92,14 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
pdo_firebird_db_handle *H = S->H;
do {
- /* named cursors should be closed first */
- if (*S->name && isc_dsql_free_statement(H->isc_status, &S->stmt, DSQL_close)) {
+ /* named or open cursors should be closed first */
+ if ((*S->name || S->cursor_open) && isc_dsql_free_statement(H->isc_status, &S->stmt, DSQL_close)) {
break;
}
-
+ S->cursor_open = 0;
/* assume all params have been bound */
- if ((S->statement_type == isc_info_sql_stmt_exec_procedure &&
- isc_dsql_execute2(H->isc_status, &H->tr, &S->stmt, PDO_FB_SQLDA_VERSION,
- S->in_sqlda, &S->out_sqlda))
- || isc_dsql_execute(H->isc_status, &H->tr, &S->stmt, PDO_FB_SQLDA_VERSION,
- S->in_sqlda)) {
+ if (isc_dsql_execute(H->isc_status, &H->tr, &S->stmt, PDO_FB_SQLDA_VERSION, S->in_sqlda)) {
break;
}
@@ -113,7 +109,8 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
}
*S->name = 0;
- S->exhausted = 0;
+ S->cursor_open = (S->out_sqlda.sqln > 0); /* A cursor is opened, when more than zero columns returned */
+ S->exhausted = !S->cursor_open;
return 1;
} while (0);
@@ -135,20 +132,16 @@ static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
strcpy(stmt->error_code, "HY000");
H->last_app_error = "Cannot fetch from a closed cursor";
} else if (!S->exhausted) {
-
- /* an EXECUTE PROCEDURE statement can be fetched from once, without calling the API, because
- * the result was returned in the execute call */
- if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
- S->exhausted = 1;
- } else {
- if (isc_dsql_fetch(H->isc_status, &S->stmt, PDO_FB_SQLDA_VERSION, &S->out_sqlda)) {
- if (H->isc_status[0] && H->isc_status[1]) {
- RECORD_ERROR(stmt);
- }
- S->exhausted = 1;
- return 0;
+ if (isc_dsql_fetch(H->isc_status, &S->stmt, PDO_FB_SQLDA_VERSION, &S->out_sqlda)) {
+ if (H->isc_status[0] && H->isc_status[1]) {
+ RECORD_ERROR(stmt);
}
+ S->exhausted = 1;
+ return 0;
}
+ if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
+ S->exhausted = 1;
+ }
return 1;
}
return 0;
@@ -161,52 +154,32 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
struct pdo_column_data *col = &stmt->columns[colno];
XSQLVAR *var = &S->out_sqlda.sqlvar[colno];
+ int colname_len;
+ char *cp;
/* allocate storage for the column */
var->sqlind = (void*)emalloc(var->sqllen + 2*sizeof(short));
var->sqldata = &((char*)var->sqlind)[sizeof(short)];
+ colname_len = (S->H->fetch_table_names && var->relname_length)
+ ? (var->aliasname_length + var->relname_length + 1)
+ : (var->aliasname_length);
col->precision = -var->sqlscale;
col->maxlen = var->sqllen;
- col->namelen = var->aliasname_length;
- col->name = estrndup(var->aliasname,var->aliasname_length);
-
- return 1;
-}
-/* }}} */
-
-#if abies_0
-/* internal function to override return types of parameters */
-static void set_param_type(enum pdo_param_type *param_type, XSQLVAR const *var) /* {{{ */
-{
- /* set the param type after the field type */
- switch (var->sqltype & ~1) {
- case SQL_INT64:
-#if SIZEOF_LONG < 8
- if (0) /* always a string if its size exceeds native long */
-#endif
- case SQL_SHORT:
- case SQL_LONG:
- if (var->sqlscale == 0) {
- *param_type = PDO_PARAM_INT;
- break;
- }
- case SQL_TEXT:
- case SQL_VARYING:
- case SQL_TYPE_DATE:
- case SQL_TYPE_TIME:
- case SQL_TIMESTAMP:
- case SQL_BLOB:
- *param_type = PDO_PARAM_STR;
- break;
- case SQL_FLOAT:
- case SQL_DOUBLE:
- *param_type = PDO_PARAM_DBL;
- break;
+ col->namelen = colname_len;
+ col->name = cp = emalloc(colname_len + 1);
+ if (colname_len > var->aliasname_length) {
+ memmove(cp, var->relname, var->relname_length);
+ cp += var->relname_length;
+ *cp++ = '.';
}
+ memmove(cp, var->aliasname, var->aliasname_length);
+ *(cp+var->aliasname_length) = '\0';
+ col->param_type = PDO_PARAM_STR;
+
+ return 1;
}
/* }}} */
-#endif
#define FETCH_BUF(buf,type,len,lenvar) ((buf) = (buf) ? (buf) : \
emalloc((len) ? (len * sizeof(type)) : ((*(unsigned long*)lenvar) = sizeof(type))))
@@ -302,15 +275,24 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
*ptr = NULL;
*len = 0;
} else {
- /* override the column param type */
- /* set_param_type(&stmt->columns[colno].param_type,var); */
- stmt->columns[colno].param_type = PDO_PARAM_STR;
-
if (var->sqlscale < 0) {
- static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000,
- 100000000, 1000000000, 1000000000, LL_LIT(10000000000),LL_LIT(100000000000),
- LL_LIT(10000000000000), LL_LIT(100000000000000),LL_LIT(1000000000000000),
- LL_LIT(1000000000000000),LL_LIT(1000000000000000000) };
+ static ISC_INT64 const scales[] = { 1, 10, 100, 1000,
+ 10000,
+ 100000,
+ 1000000,
+ 10000000,
+ 100000000,
+ 1000000000,
+ LL_LIT(10000000000),
+ LL_LIT(100000000000),
+ LL_LIT(1000000000000),
+ LL_LIT(10000000000000),
+ LL_LIT(100000000000000),
+ LL_LIT(1000000000000000),
+ LL_LIT(10000000000000000),
+ LL_LIT(100000000000000000),
+ LL_LIT(1000000000000000000)
+ };
ISC_INT64 n, f = scales[-var->sqlscale];
switch (var->sqltype & ~1) {
@@ -340,11 +322,6 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
struct tm t;
char *fmt;
-/**
-* For the time being, this code has been changed to convert every returned value to a string
-* before passing it back up to the PDO driver.
-*/
-
case SQL_VARYING:
*ptr = &var->sqldata[2];
*len = *(short*)var->sqldata;
@@ -353,7 +330,6 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
*ptr = var->sqldata;
*len = var->sqllen;
break;
-/* --- cut here --- */
case SQL_SHORT:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
*len = slprintf(*ptr, CHAR_BUF_LEN, "%d", *(short*)var->sqldata);
@@ -374,51 +350,18 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
*len = slprintf(*ptr, CHAR_BUF_LEN, "%F" , *(double*)var->sqldata);
break;
-/* --- cut here --- */
-#if abies_0
- case SQL_SHORT:
- *ptr = FETCH_BUF(S->fetch_buf[colno], long, 0, *len);
- *(long*)*ptr = *(short*)var->sqldata;
- break;
- case SQL_LONG:
-#if SIZEOF_LONG == 8
- *ptr = FETCH_BUF(S->fetch_buf[colno], long, 0, *len);
- *(long*)*ptr = *(ISC_LONG*)var->sqldata;
-#else
- *ptr = var->sqldata;
-#endif
- break;
- case SQL_INT64:
- *len = sizeof(long);
-#if SIZEOF_LONG == 8
- *ptr = var->sqldata;
-#else
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
- *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
-#endif
- break;
- case SQL_FLOAT:
- *ptr = FETCH_BUF(S->fetch_buf[colno], double, 0, *len);
- *(double*)*ptr = *(float*)var->sqldata;
- break;
- case SQL_DOUBLE:
- *ptr = var->sqldata;
- *len = sizeof(double);
- break;
-#endif
case SQL_TYPE_DATE:
isc_decode_sql_date((ISC_DATE*)var->sqldata, &t);
- fmt = INI_STR("ibase.dateformat");
+ fmt = S->H->date_format ? S->H->date_format : PDO_FB_DEF_DATE_FMT;
if (0) {
case SQL_TYPE_TIME:
isc_decode_sql_time((ISC_TIME*)var->sqldata, &t);
- fmt = INI_STR("ibase.timeformat");
+ fmt = S->H->time_format ? S->H->time_format : PDO_FB_DEF_TIME_FMT;
} else if (0) {
case SQL_TIMESTAMP:
isc_decode_timestamp((ISC_TIMESTAMP*)var->sqldata, &t);
- fmt = INI_STR("ibase.timestampformat");
+ fmt = S->H->timestamp_format ? S->H->timestamp_format : PDO_FB_DEF_TIMESTAMP_FMT;
}
-
/* convert the timestamp into a string */
*ptr = FETCH_BUF(S->fetch_buf[colno], char, *len = 80, NULL);
*len = strftime(*ptr, *len, fmt, &t);
@@ -621,13 +564,6 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
ZVAL_LONG(param->parameter, *(long*)value);
break;
}
-#if abies_0
- case PDO_PARAM_DBL:
- if (value) {
- ZVAL_DOUBLE(param->parameter, *(double*)value);
- break;
- }
-#endif
default:
ZVAL_NULL(param->parameter);
}
@@ -684,6 +620,22 @@ static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, long attr, zval *val TS
}
/* }}} */
+static int firebird_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
+{
+ pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
+
+ /* close the statement handle */
+ if ((*S->name || S->cursor_open) && isc_dsql_free_statement(S->H->isc_status, &S->stmt, DSQL_close)) {
+ RECORD_ERROR(stmt);
+ return 0;
+ }
+ *S->name = 0;
+ S->cursor_open = 0;
+ return 1;
+}
+/* }}} */
+
+
struct pdo_stmt_methods firebird_stmt_methods = { /* {{{ */
firebird_stmt_dtor,
firebird_stmt_execute,
@@ -692,7 +644,10 @@ struct pdo_stmt_methods firebird_stmt_methods = { /* {{{ */
firebird_stmt_get_col,
firebird_stmt_param_hook,
firebird_stmt_set_attribute,
- firebird_stmt_get_attribute
+ firebird_stmt_get_attribute,
+ NULL, /* get_column_meta_func */
+ NULL, /* next_rowset_func */
+ firebird_stmt_cursor_closer
};
/* }}} */
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index 5d20234e5..75aa707a1 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_firebird.c,v 1.4.2.3.2.3 2008/12/31 11:17:41 sebastian Exp $ */
+/* $Id: pdo_firebird.c,v 1.4.2.3.2.1.2.4 2008/12/31 11:15:41 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -30,7 +30,7 @@
#include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h"
-zend_function_entry pdo_firebird_functions[] = { /* {{{ */
+const zend_function_entry pdo_firebird_functions[] = { /* {{{ */
{NULL, NULL, NULL}
};
/* }}} */
@@ -55,6 +55,10 @@ ZEND_GET_MODULE(pdo_firebird)
PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
{
+ REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (long) PDO_FB_ATTR_DATE_FORMAT);
+ REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (long) PDO_FB_ATTR_TIME_FORMAT);
+ REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
+
php_pdo_register_driver(&pdo_firebird_driver);
return SUCCESS;
diff --git a/ext/pdo_firebird/php_pdo_firebird.h b/ext/pdo_firebird/php_pdo_firebird.h
index 0531e538e..c068f81a5 100644
--- a/ext/pdo_firebird/php_pdo_firebird.h
+++ b/ext/pdo_firebird/php_pdo_firebird.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_firebird.h,v 1.3.2.1.2.3 2008/12/31 11:17:42 sebastian Exp $ */
+/* $Id: php_pdo_firebird.h,v 1.3.2.1.2.1.2.3 2008/12/31 11:15:41 sebastian Exp $ */
#ifndef PHP_PDO_FIREBIRD_H
#define PHP_PDO_FIREBIRD_H
@@ -24,18 +24,6 @@
extern zend_module_entry pdo_firebird_module_entry;
#define phpext_pdo_firebird_ptr &pdo_firebird_module_entry
-#ifdef PHP_WIN32
-# ifdef PDO_FIREBIRD_EXPORTS
-# define PDO_FB_API __declspec(dllexport)
-# elif defined(COMPILE_DL_PDO_FIREBIRD)
-# define PDO_FB_API __declspec(dllimport)
-# else
-# define PDO_FB_API
-# endif
-#else
-# define PDO_FB_API
-#endif
-
#ifdef ZTS
#include "TSRM.h"
#endif
diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h
index d3755e823..bd9fa2d64 100644
--- a/ext/pdo_firebird/php_pdo_firebird_int.h
+++ b/ext/pdo_firebird/php_pdo_firebird_int.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_firebird_int.h,v 1.10.2.1.2.3 2008/12/31 11:17:42 sebastian Exp $ */
+/* $Id: php_pdo_firebird_int.h,v 1.10.2.1.2.1.2.5 2008/12/31 11:15:41 sebastian Exp $ */
#ifndef PHP_PDO_FIREBIRD_INT_H
#define PHP_PDO_FIREBIRD_INT_H
@@ -31,6 +31,10 @@
#define PDO_FB_DIALECT 3
+#define PDO_FB_DEF_DATE_FMT "%Y-%m-%d"
+#define PDO_FB_DEF_TIME_FMT "%H:%M:%S"
+#define PDO_FB_DEF_TIMESTAMP_FMT PDO_FB_DEF_DATE_FMT " " PDO_FB_DEF_TIME_FMT
+
#define SHORT_MAX (1 << (8*sizeof(short)-1))
#if SIZEOF_LONG == 8
@@ -73,6 +77,16 @@ typedef struct {
/* the last error that didn't come from the API */
char const *last_app_error;
+ /* date and time format strings, can be set by the set_attribute method */
+ char *date_format;
+ char *time_format;
+ char *timestamp_format;
+
+ /* prepend table names on column names in fetch */
+ unsigned fetch_table_names:1;
+
+ unsigned _reserved:31;
+
} pdo_firebird_db_handle;
@@ -93,7 +107,10 @@ typedef struct {
/* whether EOF was reached for this statement */
unsigned exhausted:1;
- unsigned _reserved:23;
+ /* successful isc_dsql_execute opens a cursor */
+ unsigned cursor_open:1;
+
+ unsigned _reserved:22;
/* the named params that were converted to ?'s by the driver */
HashTable *named_params;
@@ -115,6 +132,12 @@ extern struct pdo_stmt_methods firebird_stmt_methods;
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC);
+enum {
+ PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC,
+ PDO_FB_ATTR_TIME_FORMAT,
+ PDO_FB_ATTR_TIMESTAMP_FORMAT,
+};
+
#endif /* PHP_PDO_FIREBIRD_INT_H */
/*
diff --git a/ext/pdo_firebird/tests/ddl.phpt b/ext/pdo_firebird/tests/ddl.phpt
index 98a148e8f..0155d050d 100644
--- a/ext/pdo_firebird/tests/ddl.phpt
+++ b/ext/pdo_firebird/tests/ddl.phpt
@@ -3,7 +3,7 @@ PDO_Firebird: DDL/transactions
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
-<?php /* $Id: ddl.phpt,v 1.1.4.1 2009/02/09 12:56:09 felipe Exp $ */
+<?php /* $Id: ddl.phpt,v 1.1.6.1 2009/02/09 12:56:00 felipe Exp $ */
require("testdb.inc");
diff --git a/ext/pdo_firebird/tests/execute.phpt b/ext/pdo_firebird/tests/execute.phpt
index 4097f70ca..904a0a499 100644
--- a/ext/pdo_firebird/tests/execute.phpt
+++ b/ext/pdo_firebird/tests/execute.phpt
@@ -5,7 +5,7 @@ PDO_Firebird: prepare/execute/binding
--INI--
ibase.timestampformat=%Y-%m-%d %H:%M:%S
--FILE--
-<?php /* $Id: execute.phpt,v 1.4.4.1 2009/02/09 11:58:02 felipe Exp $ */
+<?php /* $Id: execute.phpt,v 1.4.6.1 2009/02/09 11:57:44 felipe Exp $ */
require("testdb.inc");