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