ZF-9255: Zend_Db_Adapter_Sqlsrv missing unicode support

Issue Type: Bug Created: 2010-02-24T08:48:14.000+0000 Last Updated: 2012-11-20T21:37:31.000+0000 Status: Open Fix version(s): Reporter: Tobias Zander (t.zander) Assignee: None Tags: - Zend_Db

Related issues: Attachments: - Sqlsrv_Unicode.patch


Current version of Zend_Db_Adapter_Sqlsrv doesn't support to query unicode characters (i.e Japanese) in the database without prepared statements. As upddate(), delete() and fetchAll() methods don't support "real" prepared statements (str_replaces are done in the methods) it's not possible to support unicode characters.

The problem lies in the _quote method of Zend_Db_Adapter_Sqlsrv, as it doesn't quote to a unicode string. Microsoft SQL Server requires an prepended N to recognize unicode strings. So a query with japanese characters has to look like this: SELECT * FROM myTable WHERE myColumn = N'[japanese characters]';

So _quote method should also prepend the N for unicode characters. For this also the Zend_Db_Statement _stripQuoted method has to be adjusted as this only works with a single quoting character, which also has to be the same at start and end.


Posted by Tobias Zander (t.zander) on 2010-02-24T09:01:42.000+0000

We created this patch to fix this problem. It prepends the required N and extends _stripQuoted to also handle this kind of quoting.

We hope this helps to fix that bug in one of the next releases.

Posted by Justinas L. (medutis) on 2010-03-25T02:47:02.000+0000

This patch could be OK, but what about prepared statements? I still can't get my unicode strings with db->update or db->insert methods

Posted by Tobias Zander (t.zander) on 2010-08-03T06:24:56.000+0000

Support for real prepared statements would be great, but is not part of this bug.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.