xref: /PHP-8.3/ext/pdo/tests/pdo_008.phpt (revision 74859783)
1--TEST--
2PDO Common: PDO::FETCH_UNIQUE conflict
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
16$db = PDOTest::factory();
17
18$db->exec('CREATE TABLE test(id CHAR(1) NOT NULL PRIMARY KEY, val VARCHAR(10))');
19$db->exec("INSERT INTO test VALUES('A', 'A')");
20$db->exec("INSERT INTO test VALUES('B', 'A')");
21$db->exec("INSERT INTO test VALUES('C', 'C')");
22
23$stmt = $db->prepare('SELECT val, id from test');
24
25$stmt->execute();
26var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_UNIQUE));
27
28?>
29--EXPECT--
30array(2) {
31  ["A"]=>
32  array(1) {
33    [0]=>
34    string(1) "B"
35  }
36  ["C"]=>
37  array(1) {
38    [0]=>
39    string(1) "C"
40  }
41}
42