Yii 如何在模型中扩展CMssqlCommandBuilder和使用扩展类
我正在使用Yii 如何在模型中扩展CMssqlCommandBuilder和使用扩展类,yii,Yii,我正在使用YII和MSSQL 尝试使用分页时,CMssqlCommandBuilder出现问题。 我使用了comment#7中给出的代码 我编辑了CMssqlCommandBuilder,我的代码运行良好 现在的问题是我不想更改Yii的CMssqlCommandBuilder类我想从CMssqlCommandBuilder扩展一个类,并使用该类 如何告诉我的模型类使用新的扩展类而不是CMssqlCommandBuilder?在基本模型类扩展CActiveRecord中覆盖getCommandBu
YII
和MSSQL
尝试使用分页时,CMssqlCommandBuilder
出现问题。
我使用了comment#7
中给出的代码
我编辑了CMssqlCommandBuilder
,我的代码运行良好
现在的问题是我不想更改Yii
的CMssqlCommandBuilder
类我想从CMssqlCommandBuilder
扩展一个类,并使用该类
如何告诉我的模型类使用新的扩展类而不是
CMssqlCommandBuilder
?在基本模型类扩展CActiveRecord中覆盖getCommandBuilder()
。
但不确定这是否是“正确的方式”
我可能更适合做以下工作:
class MyActiveRecord extends CActiveRecord
{
private $_builder;
public function getCommandBuilder()
{
if($this->_builder!==null)
return $this->_builder;
else
return $this->_builder = new MyMssqlCommandBuilder($this->getDbConnection()->getSchema());
}
}
谢谢@jborch的帖子。它成功了。
class MyActiveRecord extends CActiveRecord
{
private $_builder;
public function getCommandBuilder()
{
if($this->_builder!==null)
return $this->_builder;
else
return $this->_builder = new MyMssqlCommandBuilder($this->getDbConnection()->getSchema());
}
}