PHP  
 PHP_5_6
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt ('MySQL PDO->prepare(), emulated PS, anonymous placeholder')

Script

1: <?php
2:     
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR 'mysql_pdo_test.inc');
3:     
$db MySQLPDOTest::factory();
4:
5:     try {
6:         
$db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY1);
7:         if (
!= $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
8:             
printf("[002] Unable to switch to emulated prepared statements, test will fail\n");
9:
10:         
$db->exec('DROP TABLE IF EXISTS test');
11:         
$db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s'PDO_MYSQL_TEST_ENGINE));
12:
13:         
$stmt $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')");
14:         
// you can bind as many values as you want no matter if they can be replaced or not
15:         
$stmt->execute(array('first row'));
16:         if (
'00000' !== $stmt->errorCode())
17:             
printf("[003] Execute has failed, %s %s\n",
18:                 
var_export($stmt->errorCode(), true),
19:                 
var_export($stmt->errorInfo(), true));
20:
21:         
$stmt $db->prepare('SELECT id, label FROM test');
22:         
$stmt->execute();
23:         
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
24:
25:         
// now the same with native PS
26:         
printf("now the same with native PS\n");
27:         
$db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY0);
28:         if (
!= $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
29:             
printf("[004] Unable to switch off emulated prepared statements, test will fail\n");
30:
31:         
$db->exec('DELETE FROM test');
32:         
$stmt $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')");
33:         
// you can bind as many values as you want no matter if they can be replaced or not
34:         
$stmt->execute(array('first row'));
35:         if (
'00000' !== $stmt->errorCode())
36:             
printf("[005] Execute has failed, %s %s\n",
37:                 
var_export($stmt->errorCode(), true),
38:                 
var_export($stmt->errorInfo(), true));
39:
40:         
$stmt $db->prepare('SELECT id, label FROM test');
41:         
$stmt->execute();
42:         
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
43:
44:     } catch (
PDOException $e) {
45:         
printf("[001] %s [%s] %s\n",
46:             
$e->getMessage(), $db->errorCode(), implode(' '$db->errorInfo()));
47:     }
48:
49:     print 
"done!";
50:
?>
51:

Expected

array(1) {
  [0]=>
  array(2) {
    [%u|b%"id"]=>
    %unicode|string%(1) "1"
    [%u|b%"label"]=>
    %unicode|string%(1) "?"
  }
}
now the same with native PS
[005] Execute has failed, 'HY093' array (
  0 => 'HY093',
  1 => NULL,
  2 => NULL,
)
array(0) {
}
done!

Output

array(1) {
  [0]=>
  array(2) {
    ["id"]=>
    string(1) "1"
    ["label"]=>
    string(1) "?"
  }
}
now the same with native PS
[005] Execute has failed, 'HY093' array (
  0 => 'HY093',
  1 => NULL,
  2 => NULL,
)
Out of memory

Diff

016+ Out of memory
016- array(0) {
017- }
018- done!

 

Generated at Mon, 27 Nov 2017 05:04:32 +0000 (18 days ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.