xref: /PHP-8.1/ext/pdo_sqlite/tests/bug_42589.phpt (revision 039dd0b4)
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 (field1 VARCHAR(10))');
18$db->exec('INSERT INTO test VALUES("test")');
19
20$result = $db->query('SELECT * FROM test t1 LEFT JOIN test 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');
25var_dump(!empty($meta2['table']) && $meta2['table'] == 'test');
26?>
27--EXPECT--
28bool(true)
29bool(true)
30