xref: /PHP-5.6/ext/pdo/tests/bug_44173.phpt (revision 90fb825a)
1--TEST--
2PDO Common: Bug #44173 (PDO->query() parameter parsing/checking needs an update)
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 getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15$db = PDOTest::factory();
16
17$db->exec("CREATE TABLE test (x int)");
18$db->exec("INSERT INTO test VALUES (1)");
19
20
21// Bug entry [1]
22$stmt = $db->query();
23var_dump($stmt);
24
25
26// Bug entry [2] -- 1 is PDO::FETCH_LAZY
27$stmt = $db->query("SELECT * FROM test", PDO::FETCH_LAZY, 0, 0);
28var_dump($stmt);
29
30
31// Bug entry [3]
32$stmt = $db->query("SELECT * FROM test", 'abc');
33var_dump($stmt);
34
35
36// Bug entry [4]
37$stmt = $db->query("SELECT * FROM test", PDO::FETCH_CLASS, 0, 0, 0);
38var_dump($stmt);
39
40
41// Bug entry [5]
42$stmt = $db->query("SELECT * FROM test", PDO::FETCH_INTO);
43var_dump($stmt);
44
45
46// Bug entry [6]
47$stmt = $db->query("SELECT * FROM test", PDO::FETCH_COLUMN);
48var_dump($stmt);
49
50
51// Bug entry [7]
52$stmt = $db->query("SELECT * FROM test", PDO::FETCH_CLASS);
53var_dump($stmt);
54
55
56?>
57--EXPECTF--
58Warning: PDO::query() expects at least 1 parameter, 0 given in %s
59bool(false)
60
61Warning: PDO::query(): SQLSTATE[HY000]: General error: fetch mode doesn't allow any extra arguments in %s
62bool(false)
63
64Warning: PDO::query(): SQLSTATE[HY000]: General error: mode must be an integer in %s
65bool(false)
66
67Warning: PDO::query(): SQLSTATE[HY000]: General error: too many arguments in %s
68bool(false)
69
70Warning: PDO::query(): SQLSTATE[HY000]: General error: fetch mode requires the object parameter in %s
71bool(false)
72
73Warning: PDO::query(): SQLSTATE[HY000]: General error: fetch mode requires the colno argument in %s
74bool(false)
75
76Warning: PDO::query(): SQLSTATE[HY000]: General error: fetch mode requires the classname argument in %s
77bool(false)
78
79