I have recently taken over a project in PHP/CakePHP . Now I wanted to update the framework from CakePHP 1.3 to CakePHP 2.2. The DB-server is MS SQL Server (Version 10.50). I have also tried to connect to an SQL Sever Version 9.0 SP1. Same problem. The Application connects to the DB-server and can read text data quite nicely.
The Problem occurs if I want to read a blob/binary/image column. It seems to be a decoding problem, but I have no idea where it could occure. In the CakePHP 1.3 Version I see something like
\x2 \x0\x1xÚmŽÁN„0\x10†_¥öN...
and in the CakePHP 2.2 Version I get
0220000178DA6D8EC14E8430 ...
The stored item is a compressed XHTML File with some description tag attached. It is written by another application.
I have set the Application encoding to UTF-8, have tried to set the encoding=’utf8′ string in the Database configuration (even if it should just work for MySQL). I have updated the Native SQL Client from Microsoft. I am using a XAMPP 1.7.7 installation with a PHP 5.3.8. I have tried also a different installation with XAMPP 1.8 and new SQL-PDO Driver from Microsoft. Nothing helped.
I have no clue where this problem is coming from, even if I suspect the PDO Layer/ Driver for PHP.
The Application has worked fine with CakePHP 1.3.
Thank you for your help/time.
I figured it already out. The Problem is a known bug in PDO Layer from MS. It can be fixed with the litte function
from the comment of Marko Kozjak at http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/