Question

I integrated Doctrine 1.2 with Zend 2 and generate the models like :

- models 
     - generated
           BaseFamille.php

     Famille.php

here's the code that I included in 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>';

then I have an error in : Doctrine_Core::loadModels('db_object/models');

The error is :

Fatal error: Class 'BaseFlashCaisse' not found in ....path.... on line 14

I solve this with an include in Famille.php like :

include __DIR__.'/generated/BaseFamille.php';

but writing an include in every model is not produce way.

so is there another way to resolve this . thank you

Was it helpful?

Solution

I resolve this problem by an updated in Core.php (file of doctrine) in function loadModels, I added :

//Resolution ilyas for generated base class:
//==========================================
$mbase = $dir.'/generated/Base'.$className.'.php';
if(file_exists($mbase)){ 
    require_once $mbase;
}
//echo $file->getPathName();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top