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