내 기본 데이터베이스 어댑터를 bootstrap.php 파일에 등록하려고합니다. 그래서 내가 어디에 있든 액세스 할 수 있습니다.Zend 데이터베이스 어댑터 - bootstrap.php에 등록 하시겠습니까?
//bootstrap.php
protected function _initDb()
{
$dbAdapter = Zend_Db::factory(Zend_Registry::get('configuration')
->resources->db->adapter,
Zend_Registry::get('configuration')
->resources->db->params->toArray());
Zend_Registry::set('dbAdapter', $dbAdapter);
Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
}
그때 내 모델 중 하나에 전화를 시도하고 말하면서 :이 지금까지 내 코드입니다
Call to undefined method Application_Model_Example::_getdbAdapter() in...
:
//exampleModel.php
$select = $this->_getDbAdapter()
->select()
->from(array('t' => $this->_getTable()->getName()),
array('name'))....
그러나 난 그냥 오류를 얻고있다
그래서 분명히 현재 수업 내에서 그것을 찾고있어 그것을 찾을 수 없습니다 ...
application.ini에서이 작업을 시도해 보셨습니까? 나는 그것을하는 것이 더 좋은 곳이라고 생각한다. – vascowhite
뭐하는거야? 내가 응용 프로그램 ini에서 내 db 호스트, 이름 및 암호 등을 선언했지만 난 어댑터가 – Pjn2020
만들려고 noe 이미 만들어져 있습니다. 이거 읽었 니? http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.db – vascowhite