Hello,

I better recommend to use such approach with Doctrine:

require_once 'Doctrine.php';
$autoloader->pushAutoloader(array('Doctrine', 'autoload'),
                            array('Doctrine', 'sfYaml'));

So here you will be registering Doctrine::autoload() loader
only for classes with Doctrine_ and sfYaml_ prefixes (if you
use Doctrine_Cli data importing from YAML fixtures you'll
probably need this classes).


2010/2/21 monk.e.boy <[email protected]>:
>
> Damn it ;)
>
> I just found the answer here:
>
> http://weierophinney.net/matthew/archives/220-Autoloading-Doctrine-and-Doctrine-entities-from-Zend-Framework.html
>
> The last comment is:
>
>   This solution didn't work for me when using Doctrine::getTable('MYTABLE')
>   You also need to call add the model autoloader:
>
> $autoloader->registerNamespace('Doctrine')->pushAutoloader(array('Doctrine',
> 'modelsAutoload'), '');
>
> Which is the oposite to my problem, for me Doctrine::getTable('MYTABLE')
> worked OK, but I couldn't load the models directly.
>
>  So any hoo, to fix everything my bootstrap now has this:
>
>        protected function _initDoctrine() {
>                $this->getApplication()
>                        ->getAutoloader()
>                        ->registerNamespace('Doctrine')
>                        ->pushAutoloader(array('Doctrine', 'autoload'))
>                        ->pushAutoloader(array('Doctrine', 'modelsAutoload'), 
> '');
>
>                $options = $this->getOption('doctrine');
>                $manager = Doctrine_Manager::getInstance();
>
>                $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, 
> true);
>                $manager->setAttribute(
>                        Doctrine::ATTR_MODEL_LOADING,
>                        Doctrine::MODEL_LOADING_CONSERVATIVE
>                        );
>                $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, 
> true);
>                Doctrine::loadModels($options['models_path']);
>
>                $conn = Doctrine_Manager::connection($options['db'], 
> 'doctrine');
>                $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
>                return $conn;
>        }
>
> Then in my /models/ I have the doctrine classes like this:
>
>        class Users extends Default_Model_Generated_BaseUsers
>        {
>        }
>
> in /models/generated/  I have had to alter the class names so they look
> like:
>
>        abstract class Default_Model_Generated_BaseUsers extends 
> Doctrine_Record
>        {
>        .......
>
> Now in my Controller I can do both of these:
>
>        $u = new Users();
>        $u = Doctrine::getTable('Users');
>
> And all the JOINs and stuff work fine! Woop!
>
> Just pasted all this code in the hope it helps someone else out one day :)
>
> Thanks,
>
> monk.e.boy
>
>
>
>
>
>
> --
> View this message in context: 
> http://n4.nabble.com/auto-loader-question-tp1563248p1563255.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>



-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 617 179 344
Homepage: http://www.ixti.ru
JID: [email protected]

*Origin: Happy Hacking!

Reply via email to