Skip to content

Commit 19e297c

Browse files
committed
ext/pdo: add table as part of generic getColumnMeta
Now that we need this for ATTR_FETCH_TABLE_NAMES, we might as well make this part of the generic PDO method and not driver specific ones.
1 parent 6059e7f commit 19e297c

4 files changed

Lines changed: 3 additions & 14 deletions

File tree

‎ext/pdo/pdo_stmt.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,9 @@ PHP_METHOD(PDOStatement, getColumnMeta)
15981598
/* add stock items */
15991599
col = &stmt->columns[colno];
16001600
add_assoc_str(return_value, "name", zend_string_copy(col->name));
1601+
if (col->table && ZSTR_LEN(col->table)) {
1602+
add_assoc_str(return_value, "table", zend_string_copy(col->table));
1603+
}
16011604
add_assoc_long(return_value, "len", col->maxlen);
16021605
add_assoc_long(return_value, "precision", col->precision);
16031606
}

‎ext/pdo_mysql/mysql_statement.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,6 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *retu
827827
add_assoc_long(return_value, "pdo_type", param_type);
828828

829829
add_assoc_zval(return_value, "flags", &flags);
830-
add_assoc_string(return_value, "table", (char *) (F->table?F->table : ""));
831830

832831
PDO_DBG_RETURN(SUCCESS);
833832
} /* }}} */

‎ext/pdo_pgsql/pgsql_statement.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,6 @@ static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *r
858858
char *q=NULL;
859859
ExecStatusType status;
860860
Oid table_oid;
861-
char *table_name=NULL;
862861

863862
if (!S->result) {
864863
return FAILURE;
@@ -873,11 +872,6 @@ static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *r
873872

874873
table_oid = PQftable(S->result, colno);
875874
add_assoc_long(return_value, "pgsql:table_oid", table_oid);
876-
table_name = pdo_pgsql_translate_oid_to_table(table_oid, S->H->server);
877-
if (table_name) {
878-
add_assoc_string(return_value, "table", table_name);
879-
efree(table_name);
880-
}
881875

882876
switch (S->cols[colno].pgsql_type) {
883877
case BOOLOID:

‎ext/pdo_sqlite/sqlite_statement.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,6 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *ret
366366
add_assoc_string(return_value, "sqlite:decl_type", (char *)str);
367367
}
368368

369-
#ifdef HAVE_SQLITE3_COLUMN_TABLE_NAME
370-
str = sqlite3_column_table_name(S->stmt, colno);
371-
if (str) {
372-
add_assoc_string(return_value, "table", (char *)str);
373-
}
374-
#endif
375-
376369
add_assoc_zval(return_value, "flags", &flags);
377370

378371
return SUCCESS;

0 commit comments

Comments
 (0)