PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Aug 23, 2019 11:46 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat May 01, 2010 6:54 am 
Offline
Forum Contributor
User avatar

Joined: Tue Oct 03, 2006 2:25 pm
Posts: 385
Location: 127.0.0.1
So I'm trying to make the datamapper: Application_Model_UserMapper work as Application_Model_Mapper_User to make things look A LOT cleaner... I moved the UserMapper.php into "application/models/Mapper" and called it User.php and changed all the calls to Application_Model_Mapper_User and i still get "Fatal error: Class 'Application_Model_Mapper_Users' not found in /var/www/xxxxxx/application/controllers/IndexController.php on line 13"


So what should I do now? I thought the Zend_Loader was supposed to handle loading this file automaticly by the naming convention?

P.S.... This isn't my first ZF project but it's the first time I'm using it with a Data Mapper and I just started the project.... I'm liking the DM way of things though. :P

P.S. 2.0: I hate to start a new topic on this, but I need to know: I'm thinking about using the ZF Modules ability creating a default and admin module. If I define all the DbTables, Models, and Mappers in the default model, can they be accessed in the admin module or do I need to copy and paste them into the admin module?


Last edited by DaveTheAve on Mon May 03, 2010 12:32 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat May 01, 2010 1:19 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria
The UserMapper should be in application/models/
So if you call class Application_Model_UserMappe, it will try to load application/model/UserMapper.php
Actually the _ in the class name is the directory separator, in the default Zend Autoloader.
And Application_Model_Mapper_Users should be defined in /application/model/mapper/Users.php


Top
 Profile  
 
PostPosted: Sat May 01, 2010 3:01 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Oct 03, 2006 2:25 pm
Posts: 385
Location: 127.0.0.1
I understand that the "_" is the directory separator but if call "Application_Model_Mapper_Users", "/application/model/Mapper/Users.php" is NOT being called... and yes Application_Model_Mapper_Users IS defined in Users.php.


Top
 Profile  
 
PostPosted: Mon May 03, 2010 12:31 am 
Offline
Forum Contributor
User avatar

Joined: Tue Oct 03, 2006 2:25 pm
Posts: 385
Location: 127.0.0.1
Fixed it... ended up being a "feature" of Zend Framework.

My fix was to add this code into the bootstrap.php file:
Syntax: [ Download ] [ Hide ]
    protected function _initAutoloaders()
    {
        $loader = new Zend_Application_Module_Autoloader(array(
        'namespace' => 'Application',
        'basePath' => APPLICATION_PATH
        ));
        $loader->addResourceType ( 'mapper', 'models/Mapper', 'Model_Mapper');
        return $loader;
    }
 


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group