xref: /PHP-5.6/ext/pdo/tests/bug_43130.phpt (revision 33d872d9)
1--TEST--
2PDO Common: Bug #43130 (Bound parameters cannot have - in their name)
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');
8if (!strncasecmp(getenv('PDOTEST_DSN'), 'sqlite', strlen('sqlite'))) die('skip not relevant for sqlite driver');
9if (!strncasecmp(getenv('PDOTEST_DSN'), 'pgsql', strlen('pgsql'))) die('skip not relevant for pgsql driver');
10if (!strncasecmp(getenv('PDOTEST_DSN'), 'oci', strlen('oci'))) die('skip not relevant for oci driver - Hyphen is not legal for bind names in Oracle DB');
11if (!strncasecmp(getenv('PDOTEST_DSN'), 'firebird', strlen('firebird'))) die('skip not relevant for firebird driver');
12require_once $dir . 'pdo_test.inc';
13PDOTest::skip();
14?>
15--FILE--
16<?php
17if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
18require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
19$db = PDOTest::factory();
20
21if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql')
22	$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
23
24$db->exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))");
25
26for ($i = 0; $i < 5; $i++) {
27	$db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')");
28}
29
30$stmt = $db->prepare("SELECT a FROM test WHERE b=:id-value");
31$stmt->bindParam(':id-value', $id);
32$id = '1';
33$stmt->execute();
34var_dump($stmt->fetch(PDO::FETCH_COLUMN));
35?>
36--EXPECTF--
37Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in %s on line %d
38
39Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number in %s on line %d
40bool(false)
41