2011-01-15 6 views
-1

this tutorial을 사용하여 zend 어플리케이션에 mysql 테이블 (인증)을 연결하려고합니다. 그러나 DbTable의 인스턴스를 가져올 수 없습니다. 내 응용 프로그램에서 directory structure 만 변경했습니다.Zend에서 MySQL에 연결할 수 없습니다.

나는이 같은 매퍼 뭔가 :

class Model_Authentication_Mapper { 

    protected $_dbTable; 

    public function setDbTable($dbTable) { 

     if (is_string($dbTable)) { 
      $dbTable = new $dbTable(); 
     } 
     if (!$dbTable instanceof Zend_Db_Table_Abstract) { 
      throw new Exception('Invalid table data gateway provided'); 
     } 
     $this->_dbTable = $dbTable; 
     return $this; 
    } 

    public function getDbTable() { 

     if (null === $this->_dbTable) { 
      $this->setDbTable('Model_Authentication_DbTable'); 
     } 
     return $this->_dbTable; 
    } 

    public function getRecordById($id) { 
    $table = $this->getDbTable(); 
    // Other code here 
    } 

} 

그리고 을 DBTABLE이 같은 : 그것은 매퍼에 $table = $this->getDbTable();을 실행하면

class Model_Authentication_DbTable extends Zend_Db_Table_Abstract { 
    protected $_name = 'Authentication'; 
} 

그것은 나를 불을 지르고 콘솔에서 오류를 다음과 제공 :

An error occurred 
Application error 
Message: No adapter found for Model_Authentication_DbTable 

이 DbTable에 어댑터를 설정하는 방법은 무엇입니까?

누구나 알고있는이 ??

감사

답변

0

솔루션을 찾을 수 있습니다. 난 그냥 application.ini에서 몇 줄을 주석하고 모든 노력 :

[production] 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 
includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
bootstrap.class = "Bootstrap" 
appnamespace = "Application" 
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 
resources.frontController.params.displayExceptions = 1 

;[staging : production] 

;[testing : production] 
;phpSettings.display_startup_errors = 1 
;phpSettings.display_errors = 1 

;[development : production] 
;phpSettings.display_startup_errors = 1 
;phpSettings.display_errors = 1 
;resources.frontController.params.displayExceptions = 1 

resources.db.adapter = "pdo_mysql" 
resources.db.params.host = "localhost" 
resources.db.params.username = "root" 
resources.db.params.password = "" 
resources.db.params.dbname = "bbname" 
resources.db.isDefaultTableAdapter = true 
+2

해당 줄을 주석 처리 할 필요가 없습니다. db 정보를 [production] 섹션의 끝으로 이동하십시오. 다음 섹션은 앞의 섹션에서 구성을 상속합니다. 또한 개발하는 동안 서버 구성에 SetEnv APPLICATION_ENV 개발을 추가해야합니다. 그러면 개발 섹션의 phpSettings.display_startup_errors 등이 – user570783

+0

@ user570783에 대한 것이므로 오류를 볼 수 있습니다. 이 게시물에 관심을 가져 주셔서 감사합니다. – Awan

1

당신이 ZF 도구를 사용하여 시도? 다음 명령을 사용하여 MySQL 데이터베이스에 대한 생산 섹션에서 DB 어댑터를 만드는 데 도움이 될 것입니다

zf.sh configure db-adapter "adapter=PDO_MYSQL&host=localhost&dbname=test&username=testuser&password=testpasswort&charset=utf8" production 

그냥 당신이 MySQL을위한 PDO 드라이버가 컴퓨터에 설치해야합니다.

관련 문제