1--TEST--
2PDO::MYSQL_ATTR_INIT_COMMAND
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--INI--
12error_reporting=E_ALL
13--FILE--
14<?php
15    require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
16
17    $dsn = MySQLPDOTest::getDSN();
18    $user = PDO_MYSQL_TEST_USER;
19    $pass = PDO_MYSQL_TEST_PASS;
20
21    $table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX)));
22    $db = new PDO($dsn, $user, $pass);
23    $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
24
25    $create = sprintf('CREATE TABLE %s(id INT)', $table);
26    var_dump($create);
27    $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));
28    $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
29
30    $info = $db->errorInfo();
31    var_dump($info[0]);
32
33    $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
34    $stmt = $db->query(sprintf('SELECT id FROM %s', $table));
35    var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
36
37    $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
38    print "done!";
39?>
40--EXPECTF--
41string(58) "CREATE TABLE test_%s(id INT)"
42string(5) "00000"
43array(1) {
44  [0]=>
45  array(1) {
46    ["id"]=>
47    string(1) "1"
48  }
49}
50done!
51