xref: /PHP-7.0/ext/pdo/tests/pdo_002.phpt (revision 0a2e6f72)
1--TEST--
2PDO Common: PDO::FETCH_NUM
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_NUM));
26?>
27--EXPECT--
28array(3) {
29  [0]=>
30  array(2) {
31    [0]=>
32    string(1) "1"
33    [1]=>
34    string(1) "A"
35  }
36  [1]=>
37  array(2) {
38    [0]=>
39    string(1) "2"
40    [1]=>
41    string(1) "B"
42  }
43  [2]=>
44  array(2) {
45    [0]=>
46    string(1) "3"
47    [1]=>
48    string(1) "C"
49  }
50}
51