|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-10-21 23:22 UTC] felipe@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: mysql
[2010-11-08 18:16 UTC] uw@php.net
-Status: Assigned
+Status: Feedback
[2010-11-08 18:16 UTC] uw@php.net
[2010-11-08 20:45 UTC] novitools dot novi at web dot de
-Status: Feedback
+Status: Assigned
[2010-11-08 20:45 UTC] novitools dot novi at web dot de
[2010-11-22 10:41 UTC] uw@php.net
-Status: Assigned
+Status: Feedback
-PHP Version: 5.2.14
+PHP Version: 5.3.1
[2010-11-22 10:41 UTC] uw@php.net
[2011-01-04 16:22 UTC] uw@php.net
-Status: Feedback
+Status: Open
-Assigned To: mysql
+Assigned To:
[2011-01-04 16:22 UTC] uw@php.net
[2011-01-04 18:29 UTC] novitools dot novi at web dot de
[2014-01-01 12:47 UTC] felipe@php.net
-Package: PDO related
+Package: PDO MySQL
[2020-08-28 15:20 UTC] cmb@php.net
[2021-04-08 19:19 UTC] dharman@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2021-04-08 19:19 UTC] dharman@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ PDO Driver for MySQL, client library version 5.0.84 When using the bindColumn method of the pdo statement object, PDO converts the value Null to the number 0, if you set the type to PDO::PARAM_INT. Nevertheless PDO did'n convert a Null Value, when you select PDO::PARAM_STR as type. So PDO::PARAM_STR can handle Null-Values, but PDO::PARAM_INT can't. Test script: --------------- <?php $DB_HOST = 'localhost'; $DB_NAME = '***'; $DB_PASSWORD = '***; $DB_USERNAME = '***; $Dsn = 'mysql:host='.$DB_HOST.';dbname='.$DB_NAME; $Database = new PDO($Dsn, $DB_USERNAME, $DB_PASSWORD); $Database->setAttribute(PDO::ATTR_ERRMODE , PDO::ERRMODE_EXCEPTION); $Database->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_BOUND); $Sql = <<<SQL SELECT '', Null, 0, Null SQL; $Statement = $Database->prepare($Sql); $Statement->bindColumn(1, $Test1, PDO::PARAM_STR); // string(0) "" $Statement->bindColumn(2, $Test2, PDO::PARAM_STR); // NULL $Statement->bindColumn(3, $Test3, PDO::PARAM_INT); // int(0) $Statement->bindColumn(4, $Test4, PDO::PARAM_INT); // NULL $Statement->execute(); $Statement->fetch(); var_dump($Test1); var_dump($Test2); var_dump($Test3); var_dump($Test4); ?> Expected result: ---------------- string(0) "" NULL int(0) NULL Actual result: -------------- string(0) "" NULL int(0) int(0)