Hi!
I just needed ATTR_FETCH_TABLE_NAMES support in pdo_firebird. W/o any
knowledge about PHP politics, please let me humbly offer the
corresponding patch.
For any suggestions, please don't hesitate to contact me.
Greets
HPO
--- php5-orig/ext/pdo_firebird/firebird_driver.c 2007-11-12
16:59:34.000000000 +0100
+++ php5/ext/pdo_firebird/firebird_driver.c 2007-11-14 15:42:18.000000000
+0100
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: firebird_driver.c,v 1.23 2007/10/30 18:06:02 lwe Exp $ */
+/* $Id: firebird_driver.c,v 1.17.2.2.2.4.2.1 2007/10/30 16:30:40 lwe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -493,6 +493,11 @@
}
return 1;
+ case PDO_ATTR_FETCH_TABLE_NAMES:
+ convert_to_boolean(val);
+ H->column_name_format = Z_BVAL_P(val);
+ return 1;
+
case PDO_FB_ATTR_DATE_FORMAT:
convert_to_string(val);
if (H->date_format) {
@@ -668,7 +673,7 @@
dbh->methods = &firebird_methods;
dbh->native_case = PDO_CASE_UPPER;
dbh->alloc_own_columns = 1;
-
+
ret = 1;
} while (0);
diff -ru php5-orig/ext/pdo_firebird/firebird_statement.c
php5/ext/pdo_firebird/firebird_statement.c
--- php5-orig/ext/pdo_firebird/firebird_statement.c 2007-11-12
21:54:13.000000000 +0100
+++ php5/ext/pdo_firebird/firebird_statement.c 2007-11-14 15:45:58.000000000
+0100
@@ -169,15 +169,28 @@
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_size;
+ char *colname_runner;
+
/* allocate storage for the column */
var->sqlind = (void*)emalloc(var->sqllen + 2*sizeof(short));
var->sqldata = &((char*)var->sqlind)[sizeof(short)];
+ colname_size = (var->relname_length && S->H->column_name_format)
+ ? (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_size;
+ col->name = colname_runner = emalloc( colname_size+1 );
+ if( colname_size > var->aliasname_length ) {
+ memmove( colname_runner, var->relname, var->relname_length );
+ colname_runner += var->relname_length;
+ *colname_runner++ = '.';
+ }
+ memmove( colname_runner, var->aliasname, var->aliasname_length );
+ colname_runner += var->aliasname_length;
+ *colname_runner = 0;
col->param_type = PDO_PARAM_STR;
return 1;
diff -ru php5-orig/ext/pdo_firebird/php_pdo_firebird_int.h
php5/ext/pdo_firebird/php_pdo_firebird_int.h
--- php5-orig/ext/pdo_firebird/php_pdo_firebird_int.h 2007-11-12
16:59:35.000000000 +0100
+++ php5/ext/pdo_firebird/php_pdo_firebird_int.h 2007-11-14
13:44:28.000000000 +0100
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_firebird_int.h,v 1.13 2007/10/30 18:02:45 lwe Exp $ */
+/* $Id: php_pdo_firebird_int.h,v 1.10.2.1.2.1.2.1 2007/10/30 16:26:25 lwe Exp
$ */
#ifndef PHP_PDO_FIREBIRD_INT_H
#define PHP_PDO_FIREBIRD_INT_H
@@ -81,7 +81,7 @@
char *date_format;
char *time_format;
char *timestamp_format;
-
+ int column_name_format;
} pdo_firebird_db_handle;
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php