xref: /PHP-7.2/ext/pdo/tests/pdo_003.phpt (revision 0a2e6f72)
1--TEST--
2PDO Common: PDO::FETCH_BOTH
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 int NOT NULL PRIMARY KEY, val VARCHAR(10))');
18$db->exec("INSERT INTO test VALUES(1, 'A')");
19$db->exec("INSERT INTO test VALUES(2, 'B')");
20$db->exec("INSERT INTO test VALUES(3, 'C')");
21
22$stmt = $db->prepare('SELECT * from test');
23$stmt->execute();
24
25var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
26?>
27--EXPECT--
28array(3) {
29  [0]=>
30  array(4) {
31    ["id"]=>
32    string(1) "1"
33    [0]=>
34    string(1) "1"
35    ["val"]=>
36    string(1) "A"
37    [1]=>
38    string(1) "A"
39  }
40  [1]=>
41  array(4) {
42    ["id"]=>
43    string(1) "2"
44    [0]=>
45    string(1) "2"
46    ["val"]=>
47    string(1) "B"
48    [1]=>
49    string(1) "B"
50  }
51  [2]=>
52  array(4) {
53    ["id"]=>
54    string(1) "3"
55    [0]=>
56    string(1) "3"
57    ["val"]=>
58    string(1) "C"
59    [1]=>
60    string(1) "C"
61  }
62}
63