summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pdo_firebird/firebird_driver.c5
-rw-r--r--ext/pdo_firebird/firebird_statement.c16
-rw-r--r--ext/pdo_firebird/php_pdo_firebird_int.h5
3 files changed, 24 insertions, 2 deletions
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index 3083d07..cc71dc0 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -493,6 +493,11 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
}
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) {
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index f581e24..2b44f87 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -162,15 +162,27 @@ 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);
+ 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;
diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h
index 1728725..a9ac949 100644
--- a/ext/pdo_firebird/php_pdo_firebird_int.h
+++ b/ext/pdo_firebird/php_pdo_firebird_int.h
@@ -82,6 +82,11 @@ typedef struct {
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;