Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sqlsrv driver - binary data encoding #287
When inserting / updating a binary data to the MSSQL database, the data (output of file_get_contents) cannot be simply inserted as string value, because it rises an encoding issue (Dibi\DriverException An error occurred translating the query string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page.).
Instead of that, the binary data have to be passed as an parameter to sqlsrv_query (or sqlsrv_prepare) in following format:
More informations can be found here https://akrabat.com/some-notes-on-sql-server-blobs-with-sqlsrv/
Steps To Reproduce
Let's say we have following table:
Following code should properly create new record, with binary data
But the driver returns the mentioned error.
Now I have to use following workaround (I want to use connection from dibi, as well as generated sql query):