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