View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}


[Michael Mayer|]

0.1 - 31 May 2007: Initial draft

Zend_Db_Adapter_Odbtp_Mssql is a database adapter for the Open Database Transport Protocol (ODBTP). It enables the usage of Unicode together with MS SQL Server. The default MS SQL database driver is not binary safe and can therefore not handle UTF-16 strings because they contain null bytes.

* [Open Database Transport Protocol|]
* [Source Code|]

The database adapter requires that the odbtp extension is installed and activated (see the ODBTP for a detailed API description). A running ODBTP and SQL Server are also required to start a connection. As ODBTP uses UTF-8, there is no need for binary safe functions. Of course the multibyte extension is required to manipulate UTF-8 strings.

* Zend_Db_Adapter_Abstract
* Zend_Db_Statement

The ODBTP adapter is kind of a join of the existing ODBC (DB2) and MS SQL database adapters. It can be used as usual:

$db = Zend_Db::factory('ODBTP_MSSQL', $db_params);

It should be noted that there is a general probalem in database abstraction in Zend Framework, when dealing with date formats. ODBTP returns a date object by default; other adapters return strings for example. So this is something I would like to see fixed in future versions.

The classes are already in production use.

* Milestone 1: Check for bugs and write unit tests; test transaction support
* Milestone 3: Write documentation

* Zend_Db_Statement_Odbtp_Mssql
* Zend_Db_Statement_Odbtp_Exception
* Zend_Db_Adapter_Odbtp_Mssql
* Zend_Db_Adapter_Odbtp_Exception

The typical use case is storing Unicode (UTF-8) strings in MS SQL databases.


class Zend_Db_Adapter_Odbtp_Mssql extends Zend_Db_Adapter_Abstract {
protected $_config;
protected $_execute_mode;
protected $_lastInsertTable;
public function __construct(Array $config);
protected function _beginTransaction();
protected function _commit();
protected function _connect();
protected function _getExecuteMode();
protected function _quote($value);
public function describeTable($table, $schemaNAME = null);
public function fetchAssoc($sql, $bind);
public function insert($table, $bind);
public function lastInsertId($tableName, $primaryKey);
public function limit($sql, $count, $offset);
public function listTables();
public function prepare($sql);
public function quoteIdentifier($ident);
public function setFetchMode($mode);
public function update($table, $bind, $where);


The full source can be downloaded here: