学习zend framework1.5,我想看看它换个数据库是不是会有问题,于是我把akrabat例子中的脚本改成sqlserver的。
结果
新增编辑删除都报错。
经过一番摸索,找到原因了,Zf1.5 zend/db/select.php生成查询字符串出错了。它把生成的条件全部加到后面,而sqlserver需要修改相应的Sql
Zend\Db\Select.php
问题自己修复如下:
__toString()函数修改如下
/**
* Converts this object to an SQL SELECT string.
*
* @return string This object as a SELECT string.
*/
public function __toString()
{
$sql = array(self::SQL_SELECT);
foreach (array_keys(self::$_partsInit) as $part) {
$method = '_render' . ucfirst($part);
if (method_exists($this, $method)) {
if(ucfirst($part)=='Limitoffset')
{
$tmpstr=implode(' ', array_filter($sql));
unset($sql);
$sql[] = $this->$method($tmpstr);
}
else
$sql[] = $this->$method();
}
}
return implode(' ', array_filter($sql));
}
|
_renderLimitoffset函数修改:
/**
* Render LIMIT OFFSET clause
*
* @return string|null
*/
protected function _renderLimitoffset($sqlstr = null)
{
$count = 0;
$offset = 0;
if (!empty($this->_parts[self::LIMIT_OFFSET])) {
$offset = (int) $this->_parts[self::LIMIT_OFFSET];
// This should reduce to the max integer PHP can support
$count = intval(9223372036854775807);
}
if (!empty($this->_parts[self::LIMIT_COUNT])) {
$count = (int) $this->_parts[self::LIMIT_COUNT];
}
/*
* Add limits clause
*/
if ($count > 0) {
return trim($this->_adapter->limit($sqlstr , $count, $offset));
}
return $sqlstr;
}
|
Zend怎么改我就管不着了,这样反证解决了我的问题。
阅读(1214) | 评论(1) | 转发(0) |