mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
MFH Add table key to getColumnMeta() with SQLite
This commit is contained in:
parent
fc044adb9f
commit
efaba65cf5
4 changed files with 37 additions and 2 deletions
|
@ -79,7 +79,12 @@ if test "$PHP_PDO_SQLITE" != "no"; then
|
||||||
threadsafe_flags="-DSQLITE_THREADSAFE=0"
|
threadsafe_flags="-DSQLITE_THREADSAFE=0"
|
||||||
fi
|
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
|
if test "$PHP_SQLITE3" != "yes"; then
|
||||||
PHP_ADD_SOURCES(PHP_EXT_DIR(sqlite3), libsqlite/sqlite3.c)
|
PHP_ADD_SOURCES(PHP_EXT_DIR(sqlite3), libsqlite/sqlite3.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);
|
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);
|
add_assoc_zval(return_value, "flags", flags);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
|
23
ext/pdo_sqlite/tests/bug_42589.phpt
Normal file
23
ext/pdo_sqlite/tests/bug_42589.phpt
Normal file
|
@ -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)
|
|
@ -67,7 +67,7 @@ if test $PHP_SQLITE3 != "no"; then
|
||||||
debug_flags="-DSQLITE_DEBUG=1"
|
debug_flags="-DSQLITE_DEBUG=1"
|
||||||
fi
|
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
|
dnl As long as intl is not shared we can have ICU support
|
||||||
if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then
|
if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue