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