简体   繁体   中英

zend doctrine couldn't find class

Executing in method checkUnique the line $res=$select->fetchArray(); in the following class I get an error which I cannot solve.

I think it is due to the naming conventions zend autoloader

class Twit_Model_Owners extends Twit_Model_BaseOwners {

    function checkUnique($username) {
        $con = Doctrine_Manager::getInstance()->connection();
        $select = $con->createQuery();
        $select->from($this->getTable()->getTableName(), array('loginName'))
                ->where('loginName=?', $username);
        $res=$select->fetchArray();

        if (empty($res)) {
            return true;
        }
        return false;
    }
}

The exception:

Application error

Exception information:

Message: Couldn't find class Owners
Stack trace:

#0 /usr/share/php/Doctrine/lib/Doctrine/Table.php(256): Doctrine_Table->initDefinition()
#1 /usr/share/php/Doctrine/lib/Doctrine/Connection.php(1126): Doctrine_Table->__construct('Owners', Object(Doctrine_Connection_Mysql), true)
#2 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1942): Doctrine_Connection->getTable('Owners')
#3 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1740): Doctrine_Query->loadRoot('Owners', 'Owners')
#4 /usr/share/php/Doctrine/lib/Doctrine/Query/From.php(88): Doctrine_Query->load('Owners')
#5 /usr/share/php/Doctrine/lib/Doctrine/Query/Abstract.php(2077): Doctrine_Query_From->parse('Owners')
#6 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1167): Doctrine_Query_Abstract->_processDqlQueryPart('from', Array)
#7 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1133): Doctrine_Query->buildSqlQuery(true)
#8 /usr/share/php/Doctrine/lib/Doctrine/Query/Abstract.php(958): Doctrine_Query->getSqlQuery(Array)
#9 /usr/share/php/Doctrine/lib/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
#10 /usr/share/php/Doctrine/lib/Doctrine/Query.php(267): Doctrine_Query_Abstract->execute(Array, 3)
#11 /var/www/twit/application/models/Owners.php(20): Doctrine_Query->fetchArray()
#12 /var/www/twit/application/controllers/AuthController.php(62): Twit_Model_Owners->checkUnique('a')
#13 /usr/share/php/libzend-framework-php/Zend/Controller/Action.php(516): AuthController->signupAction()
#14 /usr/share/php/libzend-framework-php/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('signupAction')
#15 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#16 /usr/share/php/libzend-framework-php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#17 /usr/share/php/libzend-framework-php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#18 /var/www/twit/public/index.php(30): Zend_Application->run()
#19 {main}  

Request Parameters:

array (
  'module' => 'default',
  'controller' => 'auth',
  'action' => 'signup',
  'username' => 'a',
  'password' => 'x',
  'confirmPassword' => 'x',
  'captcha' => 
  array (
    'id' => 'ae5e3ce58bcf69e25ccdbba601029325',
    'input' => 'hen753',
  ),
  'register' => 'Sign up',
)  

I can instantiate models without problem. This is the code i use to generate models:

  Doctrine::generateModelsFromDb('/var/www/twit/application/models', array('zenddb'), array(
            'baseClassesDirectory' => '',
            'classPrefix' => 'Twit_Model_',
            'classPrefixFiles' => false
            ));

Furthermore, if you want, you can visit the sample page here and get the error by yourself here.

http://94.94.19.135/twit/public/index.php/signup

似乎Doctrine不想使用$this->getTable()->getTableName()返回的表名,但是我个人不知道该对象的名称(在我的情况下为Twit_Model_Owners)(抽象为好的,但至少应保留查询构建器中表的名称),但我抱怨。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM