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