Skip to content

Commit 6d5e6f7

Browse files
committed
fix test
1 parent 7f23398 commit 6d5e6f7

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

ext/pdo_mysql/tests/gh13384.phpt

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,48 @@ $db = MySQLPDOTest::factory();
1414
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1515
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
1616

17-
$db->exec('CREATE TABLE test_gh13384 (mode TINYINT)');
18-
19-
$stringableObject = new class () {
17+
$stringableObject = new class () implements Stringable {
2018
public function __toString(): string
2119
{
22-
return 'I am stringable object';
20+
return '555';
2321
}
2422
};
2523

2624
echo "Stringable object, bindValue:\n";
27-
try {
28-
$stmt = $db->prepare('INSERT INTO test_gh13384 (mode) VALUES (?)');
29-
$stmt->bindValue(1, $stringableObject, PDO::PARAM_INT);
30-
$stmt->execute();
31-
} catch (Throwable $e) {
32-
echo $e->getMessage()."\n\n";
33-
}
25+
$stmt = $db->prepare('SELECT (?)');
26+
$stmt->bindValue(1, $stringableObject, PDO::PARAM_INT);
27+
$stmt->execute();
28+
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
29+
echo "\n";
3430

3531
echo "Normal object, bindValue:\n";
3632
try {
37-
$stmt = $db->prepare('INSERT INTO test_gh13384 (mode) VALUES (?)');
38-
$stmt->bindValue(1, new DateTime(), PDO::PARAM_INT);
33+
$stmt = $db->prepare('SELECT (?)');
34+
$stmt->bindValue(1, new stdClass(), PDO::PARAM_INT);
3935
$stmt->execute();
4036
} catch (Throwable $e) {
4137
echo $e->getMessage()."\n\n";
4238
}
4339

4440
echo "Array, bindParam:\n";
4541
try {
46-
$stmt = $db->prepare('INSERT INTO test_gh13384 (mode) VALUES (?)');
42+
$stmt = $db->prepare('SELECT (?)');
4743
$param = ['aaa'];
4844
$stmt->bindParam(1, $param, PDO::PARAM_INT);
4945
$stmt->execute();
5046
} catch (Throwable $e) {
5147
echo $e->getMessage();
5248
}
5349
?>
54-
--CLEAN--
55-
<?php
56-
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
57-
$db = MySQLPDOTest::factory();
58-
$db->exec('DROP TABLE IF EXISTS test_gh13384');
59-
?>
6050
--EXPECT--
6151
Stringable object, bindValue:
62-
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'I am stringable object' for column 'mode' at row 1
52+
array(1) {
53+
[0]=>
54+
array(1) {
55+
["?"]=>
56+
string(3) "555"
57+
}
58+
}
6359

6460
Normal object, bindValue:
6561
SQLSTATE[HY105]: Invalid parameter type: Expected a scalar value or null

0 commit comments

Comments
 (0)