Bug #72414 [Opn->Csd]: MSSQL BindParam with UTF8 Character then Char modified
| From: | adambaratz@php.net | Date: | Wed, 14 Sep 2016 21:47:15 +0000 |
| Subject: | Bug #72414 [Opn->Csd]: MSSQL BindParam with UTF8 Character then Char modified | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204045@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72414&edit=1
ID: 72414
Updated by: adambaratz@php.net
Reported by: sungtae542 at gmail dot com
Summary: MSSQL BindParam with UTF8 Character then Char
modified
-Status: Open
+Status: Closed
Type: Bug
Package: PDO DBlib
Operating System: Ubunbu 16.04
PHP Version: 7.0.7
-Assigned To:
+Assigned To: adambaratz
Block user comment: N
Private report: N
New Comment:
This will be fixed with the next 7.0.x release:
https://github.com/php/php-src/commit/2302eef5c93b722d5311549dd59d495ff11d3b0d
Previous Comments:
------------------------------------------------------------------------
[2016-08-01 05:21:07] sungtae542 at gmail dot com
Ubuntu 16.04 + PHP7.0.8 PDO_dblib + parambind(UTF8) + mssql : Fail
Ubuntu 16.04 + PHP7.0.8 PDO_dblib + UTF8 query + mssql : OK
Only mssql + parambind + PHP7.0.x is broken
mssql + parambind + PHP5.5.9 is working.
mssql + NO-parambind + PHP7.0.x is working.
mysql + parambind + PHP7.0.x is working.
I check at freetds debug log and mssql query profiler.
------------------------------------------------------------------------
[2016-07-01 21:43:41] kir dot morozov at gmail dot com
I can confirm, no matter what was put to charset, encoding stays same,
------------------------------------------------------------------------
[2016-06-15 14:48:27] sungtae542 at gmail dot com
Description:
------------
MSSQL BindParam with UTF8 Character in PHP 7.0.4 and PHP 7.0.7
then UTF8 character is modified.
PHP 5.5.6 is OK.
PHP 7.0 without bindparam and just pdo-dblib with UTF8 is ok.
PHP 7.0 with bindparam pdo-mysql UTF8 is ok.
PHP 7.0.4-7ubuntu2.1 (Ubuntu 16.04 Package)
PHP 7.0.7 (php-7.0.7.tar.gz)
Ubuntu 16.04 + PHP7.0.4 PDO_dblib + parambind(UTF8) + mssql : Fail
Ubuntu 16.04 + PHP7.0.7 PDO_dblib + parambind(UTF8) + mssql : Fail
Ubuntu 16.04 + PHP7.0.? PDO_dblib + parambind(Ansi) + mssql : OK
Ubuntu 14.04 + PHP5.5.9 PDO_dblib + parambind(UTF8) + mssql : OK
Ubuntu 16.04 + PHP7.0.4 PDO_dblib + UTF8 query + mssql : OK
Ubuntu 16.04 + PHP7.0.4 PDO_mysql + parambind(UTF8) + mysql : OK
Ubuntu 16.04 + freetds + tsql + mssql : OK
Test script:
---------------
# with bindparam
$pdo = new PDO("dblib:host=$dbIp;dbname=$dbName;charset=UTF-8", $dbId, $dbPw);
#$username = 'username1';
$username = 'íê¸';
$sth = $pdo->prepare("select * from test_table where username = :username");
$sth->bindParam (':username', $username);
$sth->execute();
$row = $sth->fetch(PDO::FETCH_OBJ);
var_dump($row);
#without bindparam
$pdo = new PDO("dblib:host=$dbIp;dbname=$dbName;charset=UTF-8", $dbId, $dbPw);
#$username = 'username1';
$username = "'" . "íê¸" . "'";
$sth = $pdo->prepare("select * from test_table where username = $username");
$sth->execute();
$row = $sth->fetch(PDO::FETCH_OBJ);
var_dump($row);
Expected result:
----------------
freetds debug log and MSSQL Profiler log is following
select * from test_table where username = 'íê¸'
Actual result:
--------------
freetds debug log and MSSQL Profiler log is following
select * from test_table where username = 0x27ed959ceab88027
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72414&edit=1