@@ -14,52 +14,48 @@ $db = MySQLPDOTest::factory();
14
14
$ db ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
15
15
$ db ->setAttribute (PDO ::ATTR_EMULATE_PREPARES , false );
16
16
17
- $ db ->exec ('CREATE TABLE test_gh13384 (mode TINYINT) ' );
18
-
19
- $ stringableObject = new class () {
17
+ $ stringableObject = new class () implements Stringable {
20
18
public function __toString (): string
21
19
{
22
- return 'I am stringable object ' ;
20
+ return '555 ' ;
23
21
}
24
22
};
25
23
26
24
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" ;
34
30
35
31
echo "Normal object, bindValue: \n" ;
36
32
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 );
39
35
$ stmt ->execute ();
40
36
} catch (Throwable $ e ) {
41
37
echo $ e ->getMessage ()."\n\n" ;
42
38
}
43
39
44
40
echo "Array, bindParam: \n" ;
45
41
try {
46
- $ stmt = $ db ->prepare ('INSERT INTO test_gh13384 (mode) VALUES (?) ' );
42
+ $ stmt = $ db ->prepare ('SELECT (?) ' );
47
43
$ param = ['aaa ' ];
48
44
$ stmt ->bindParam (1 , $ param , PDO ::PARAM_INT );
49
45
$ stmt ->execute ();
50
46
} catch (Throwable $ e ) {
51
47
echo $ e ->getMessage ();
52
48
}
53
49
?>
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
- ?>
60
50
--EXPECT--
61
51
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
+ }
63
59
64
60
Normal object, bindValue:
65
61
SQLSTATE[HY105]: Invalid parameter type: Expected a scalar value or null
0 commit comments