1--TEST--
2MySQL PDO->prepare(), native PS, named placeholder
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9$db = MySQLPDOTest::factory();
10?>
11--FILE--
12<?php
13    require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14    $db = MySQLPDOTest::factory();
15    MySQLPDOTest::createTestTable($db);
16
17    $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0);
18    if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
19        printf("[002] Unable to turn off emulated prepared statements\n");
20
21    $stmt = $db->prepare("SELECT :param FROM test ORDER BY id ASC LIMIT 1");
22    $stmt->execute(array(':param' => 'id'));
23    var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
24
25    $db->prepare('SELECT :placeholder FROM test WHERE :placeholder > :placeholder');
26    $stmt->execute(array(':placeholder' => 'test'));
27
28    var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
29
30    print "done!";
31?>
32--CLEAN--
33<?php
34require __DIR__ . '/mysql_pdo_test.inc';
35$db = MySQLPDOTest::factory();
36$db->exec('DROP TABLE IF EXISTS test');
37?>
38--EXPECTF--
39array(1) {
40  [0]=>
41  array(1) {
42    ["?"]=>
43    string(2) "id"
44  }
45}
46
47Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in %s on line %d
48array(0) {
49}
50done!
51