PDO SQLSRV And PDO Dblib Giving Different Result for Varbinary Datatype

335 views Asked by At
$conn = new PDO("sqlsrv:server=$host;Database=$db",$user,$pass);
$query = "SELECT TOP 1 CAST(session AS VARBINARY(MAX)) as session FROM t_php_session WHERE php_session_id = '3l7kmpbno002e1vl5sncauhoq3' AND DATEADD(minute, 30, created) >= GETDATE() AND user_ip = '127000000001'";
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->fetchColumn();
echo $result;

The output of above code in Linux (PDO, DBLIB) is:

Custome_Core_Session|a:1:{s:16:"Custome_Core_Session";a:4:{s:19:"previous_controller";N;s:15:"previous_action";N;s:18:"current_controller";s:16:"authentification";s:14:"current_action";s:5:"login";}}

The output of above code in Windows (PDO, SQLSRV) is:

4D00630064005F0043006F00720065005F00530065007300730069006F006E007C0061003A0031003A007B0073003A00310036003A0022004D00630064005F0043006F00720065005F00530065007300730069006F006E0022003B0061003A0034003A007B0073003A00310039003A002200700072006500760069006F00750073005F0063006F006E00740072006F006C006C006500720022003B004E003B0073003A00310035003A002200700072006500760069006F00750073005F0061006300740069006F006E0022003B004E003B0073003A00310038003A002200630075007200720065006E0074005F0063006F006E00740072006F006C006C006500720022003B0073003A00310036003A002200610075007400680065006E00740069006600690063006100740069006F006E0022003B0073003A00310034003A002200630075007200720065006E0074005F0061006300740069006F006E0022003B0073003A0035003A0022006C006F00670069006E0022003B007D007D00

What changes I will need to make in Windows source code to get the output as same as Linux System?

0

There are 0 answers