diff options
author | Scott MacVicar <scottmac@php.net> | 2009-01-13 02:50:54 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2009-01-13 02:50:54 +0000 |
commit | efaba65cf5aa5e6469bd6c53637b950934dccd44 (patch) | |
tree | 223661e3bcfdcca120e58d72d0c2daf724108816 | |
parent | fc044adb9fac7675fec420fb74a4de3d7c6521d1 (diff) | |
download | php-git-efaba65cf5aa5e6469bd6c53637b950934dccd44.tar.gz |
MFH Add table key to getColumnMeta() with SQLite
-rw-r--r-- | ext/pdo_sqlite/config.m4 | 7 | ||||
-rw-r--r-- | ext/pdo_sqlite/sqlite_statement.c | 7 | ||||
-rw-r--r-- | ext/pdo_sqlite/tests/bug_42589.phpt | 23 | ||||
-rw-r--r-- | ext/sqlite3/config0.m4 | 2 |
4 files changed, 37 insertions, 2 deletions
diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4 index fb06fd79e3..4e6dd2cb12 100644 --- a/ext/pdo_sqlite/config.m4 +++ b/ext/pdo_sqlite/config.m4 @@ -79,7 +79,12 @@ if test "$PHP_PDO_SQLITE" != "no"; then threadsafe_flags="-DSQLITE_THREADSAFE=0" fi - other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_CORE=1" + other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1" + + dnl As long as intl is not shared we can have ICU support + if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then + other_flags="$other_flags -DSQLITE_ENABLE_ICU=1" + fi if test "$PHP_SQLITE3" != "yes"; then PHP_ADD_SOURCES(PHP_EXT_DIR(sqlite3), libsqlite/sqlite3.c) diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index 3a5523d2f6..63598901a0 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -323,6 +323,13 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_v add_assoc_string(return_value, "sqlite:decl_type", str, 1); } +#ifdef SQLITE_ENABLE_COLUMN_METADATA + str = sqlite3_column_table_name(S->stmt, colno); + if (str) { + add_assoc_string(return_value, "table", str, 1); + } +#endif + add_assoc_zval(return_value, "flags", flags); return SUCCESS; diff --git a/ext/pdo_sqlite/tests/bug_42589.phpt b/ext/pdo_sqlite/tests/bug_42589.phpt new file mode 100644 index 0000000000..abd5e8cea7 --- /dev/null +++ b/ext/pdo_sqlite/tests/bug_42589.phpt @@ -0,0 +1,23 @@ +--TEST-- +PDO SQLite Feature Request #42589 (getColumnMeta() should also return table name) +--SKIPIF-- +<?php +if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) die('skip not loaded'); +?> +--FILE-- +<?php +$db = new PDO("sqlite::memory:"); + +$db->exec('CREATE TABLE test (field1 VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES("test")'); + +$result = $db->query('SELECT * FROM test t1 LEFT JOIN test t2 ON t1.field1 = t2.field1'); +$meta1 = $result->getColumnMeta(0); +$meta2 = $result->getColumnMeta(1); + +var_dump(!empty($meta1['table']) && $meta1['table'] == 'test'); +var_dump(!empty($meta2['table']) && $meta2['table'] == 'test'); +?> +--EXPECTF-- +bool(true) +bool(true) diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4 index 60d96b4af5..5c9ddb3f93 100644 --- a/ext/sqlite3/config0.m4 +++ b/ext/sqlite3/config0.m4 @@ -67,7 +67,7 @@ if test $PHP_SQLITE3 != "no"; then debug_flags="-DSQLITE_DEBUG=1" fi - other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_CORE=1" + other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1" dnl As long as intl is not shared we can have ICU support if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then |