Registering Zend Database Adapter in Registry

后端 未结 9 2027
温柔的废话
温柔的废话 2020-12-23 00:07

I am looking to register a reference to the main Database Adapter in the Registry during Bootstrapping so it can be used elsewhere in my site (specifically the Authorisation

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 00:39

    I have a method in my bootstrap to add the adapter to the registry. I'd prefer a cleaner solution, but it works:

    protected function _initRegistry(){
    
        $this->bootstrap('db');
        $db = $this->getResource('db');
    
        $db->setFetchMode(Zend_Db::FETCH_OBJ);
    
        Zend_Registry::set('db', $db);
    }
    

提交回复
热议问题