我将Doctrine 1.2与Zend 2集成在一起,并生成如下模型:
- models
- generated
BaseFamille.php
Famille.php
这里是我在global.php中包含的代码:
require_once('vendor/pgit/doctrine/Doctrine.php');
spl_autoload_register(array('Doctrine_Core', 'autoload'));
//spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
$doctrine_connection = Doctrine_Manager::connection($dsn, 'doctrine');
$doctrine_connection->setCharset('utf8');
$manager = Doctrine_Manager::getInstance();
$manager->setCollate('utf8_general_ci');
$manager->setCharset('utf8');
$manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true);
spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
Doctrine_Core::loadModels('db_object/models');
//echo 'Doctrine is loaded<br>';
然后我在Doctrine_Core::loadModels('db_object/models');
错误是:
Fatal error: Class 'BaseFlashCaisse' not found in ....path.... on line 14
我用Famille.php中的include来解决这个问题:
include __DIR__.'/generated/BaseFamille.php';
但是在每个模型中编写包含都不是生产方式。
还有另一种解决方法。 谢谢
答案 0 :(得分:0)
我通过在函数loadModels中更新了Core.php(doctrine文件)解决了这个问题,我补充道:
//Resolution ilyas for generated base class:
//==========================================
$mbase = $dir.'/generated/Base'.$className.'.php';
if(file_exists($mbase)){
require_once $mbase;
}
//echo $file->getPathName();