NeatCN(NeatStudio工作室) NeatStudio工作室

Posts Tagged ‘bootstrap’

为Zend的table加上prefix

03.24.2010 · Posted in PHP开发

我不知道别人是怎么做的。我做的很累啊。。。明明在继承Zend_Db_Table_Abstract的类中打印getAdapter方法时,有_config变量,但是,它是protected的,没有找到合适的方法调用。 于是没办法。到bootstrap.php文件里加了一个方法。 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected $_bootConfig; public function __construct( $application ) { parent::__construct($application); $this->_bootConfig = new Zend_Config_Ini( APPLICATION_PATH . '/configs/application.ini' ); Zend_Registry::set('config', $this->_bootConfig); } } 这样。我在bootstrap中也能直接使用 $this->_bootConfig 的变量。因为我使用了smarty,而且用的不是继承的方法。所以直接在__construct方法中把config变量赋值出来也有一定的方便之处。 就象这样: public function _initView() { require_once ('Smarty/Smarty.class.php'); $tpl = new Smarty(); $tplSettings = $this->_bootConfig->staging->smarty->toArray(); foreach( $tplSettings as $key=>$value){ $tpl->$key = $value; } Zend_Registry::set( 'tpl', ...