日志
在Zend Server CE中使用Zend_Db/sqlsrv/utf8连接MSSQL
2011-06-12 12:22
原文见:http://hi.baidu.com/xchinux/blog/item/3ba84936359db6c5a3cc2b88.html
在Zend Server CE中已经内置了sqlsrv驱动,在Zend_Db中以UTF-8字符集连接MSSQL步骤如下: 首先数据表的字符串必须是unicode格式的,即为nchar、nvarchar、ntext等类型的。 $param = array('host' => 'localhost', 'username' => 'sa', 'password' => '123456', 'dbname' => 'test', 'driver_options' => array('CharacterSet' => 'UTF-8')); $db = Zend_Db::factory('SQLSRV', $param); $sel = $db->select(); $sel->from('t1', array('f1','f2')); $sel->order('f1 DESC'); $sel->limit(10, 20); $result = $db->query($sel->__toString()); $rows = $result->fetchAll(); print_r($rows) |