xref: /php-src/ext/pdo_sqlite/tests/bug_42589.phpt (revision 417f3fdb)
1--TEST--
2PDO SQLite Feature Request #42589 (getColumnMeta() should also return table name)
3--EXTENSIONS--
4pdo
5pdo_sqlite
6--SKIPIF--
7<?php
8$db = new PDO("sqlite::memory:");
9$options = $db->query('PRAGMA compile_options')->fetchAll(PDO::FETCH_COLUMN);
10if(!in_array('ENABLE_COLUMN_METADATA', $options, true))
11    die("skip sqlite3 must be compiled with SQLITE_ENABLE_COLUMN_METADATA");
12?>
13--FILE--
14<?php
15$db = new PDO("sqlite::memory:");
16
17$db->exec('CREATE TABLE test_42589 (field1 VARCHAR(10))');
18$db->exec('INSERT INTO test_42589 VALUES("test")');
19
20$result = $db->query('SELECT * FROM test_42589 t1 LEFT JOIN test_42589 t2 ON t1.field1 = t2.field1');
21$meta1 = $result->getColumnMeta(0);
22$meta2 = $result->getColumnMeta(1);
23
24var_dump(!empty($meta1['table']) && $meta1['table'] == 'test_42589');
25var_dump(!empty($meta2['table']) && $meta2['table'] == 'test_42589');
26?>
27--EXPECT--
28bool(true)
29bool(true)
30