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/bug_44707.phpt ('Bug #44707 (The MySQL PDO driver resets variable content after bindParam on tinyint field)')

Script

1: <?php
2:
require dirname(__FILE__) . '/config.inc';
3: require 
dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
4:
$db PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
5:
6: function 
bug_44707($db) {
7:
8:     
$db->exec('DROP TABLE IF EXISTS test');
9:     
$db->exec('CREATE TABLE test(id INT, mybool TINYINT)');
10:
11:     
$id 1;
12:     
$mybool false;
13:     
var_dump($mybool);
14:
15:     
$stmt $db->prepare('INSERT INTO test(id, mybool) VALUES (?, ?)');
16:     
$stmt->bindParam(1$id);
17:     
// From MySQL 4.1 on boolean and TINYINT don't match! INSERT will fail.
18:     // Versions prior to 4.1 have a weak test and will accept this.
19:     
$stmt->bindParam(2$myboolPDO::PARAM_BOOL);
20:     
var_dump($mybool);
21:
22:     
$stmt->execute();
23:     
var_dump($mybool);
24:
25:     
$stmt $db->query('SELECT * FROM test');
26:     
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
27:
28:     
$stmt $db->prepare('INSERT INTO test(id, mybool) VALUES (?, ?)');
29:     
$stmt->bindParam(1$id);
30:     
// INT and integer work well together
31:     
$stmt->bindParam(2$myboolPDO::PARAM_INT);
32:     
$stmt->execute();
33:
34:     
$stmt $db->query('SELECT * FROM test');
35:     
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
36:
37: }
38:
39:
40:
/*
41: // This is beyond the control of the driver... - the driver never gets in touch with bound values
42: print "Emulated Prepared Statements\n";
43: $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
44: bug_44707($db);
45: */
46:
47:
print "Native Prepared Statements\n";
48:
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES0);
49:
bug_44707($db);
50:
51: print 
"done!";
52:
?>
53:

Expected

Native Prepared Statements
bool(false)
bool(false)
bool(false)
array(0) {
}
array(1) {
  [0]=>
  array(2) {
    [%u|b%"id"]=>
    %unicode|string%(1) "1"
    [%u|b%"mybool"]=>
    %unicode|string%(1) "0"
  }
}
done!

Output

Native Prepared Statements
bool(false)
bool(false)
bool(false)
Out of memory

Diff

005+ Out of memory
005- array(0) {
006- }
007- array(1) {
008-   [0]=>
009-   array(2) {
010-     [%u|b%"id"]=>
011-     %unicode|string%(1) "1"
012-     [%u|b%"mybool"]=>
013-     %unicode|string%(1) "0"
014-   }
015- }
016- done!

 

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

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