xref: /PHP-7.3/ext/pdo_mysql/tests/bug53551.phpt (revision fc49f76c)
1--TEST--
2Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8$db = MySQLPDOTest::factory();
9?>
10--FILE--
11<?php
12include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
13$db = MySQLPDOTest::factory();
14
15$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
16
17$createSql = "CREATE TABLE `bug53551` (
18  `count` bigint(20) unsigned NOT NULL DEFAULT '0'
19)";
20
21$db->exec('drop table if exists bug53551');
22$db->exec($createSql);
23$db->exec("insert into bug53551 set `count` = 1 ");
24$db->exec("SET sql_mode = 'Traditional'");
25$sql = 'UPDATE bug53551 SET `count` = :count';
26$stmt = $db->prepare($sql);
27
28$values = array (
29    'count' => NULL,
30);
31
32echo "1\n";
33$stmt->execute($values);
34var_dump($stmt->errorInfo());
35
36echo "2\n";
37$stmt->execute($values);
38var_dump($stmt->errorInfo());
39
40echo "\ndone\n";
41
42?>
43--CLEAN--
44<?php
45include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
46$db = MySQLPDOTest::factory();
47$db->exec('DROP TABLE IF EXISTS bug53551');
48?>
49--EXPECTF--
501
51
52Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'count' cannot be null in %s on line %d
53array(3) {
54  [0]=>
55  string(5) "23000"
56  [1]=>
57  int(1048)
58  [2]=>
59  string(29) "Column 'count' cannot be null"
60}
612
62
63Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'count' cannot be null in %s on line %d
64array(3) {
65  [0]=>
66  string(5) "23000"
67  [1]=>
68  int(1048)
69  [2]=>
70  string(29) "Column 'count' cannot be null"
71}
72
73done
74