Question

I am currently working an a Zend framework 1.12 based project. I use different modules to keep things separated as good as possible. My data is stored in a mysql database so I set up some db table models inside my project. The relation between the tables should be handled by Zend frameworks Zend_Db_Table Relationships. I added the necessary code to my classes:

class User_Model_DbTable_Users extends Zend_Db_Table_Abstract
{
    protected $_name = 'users';
    protected $_primary = 'user_id';

    protected $_dependentTables = array('Diagnostics_Model_DbTable_Diagnostics');
}

User_Model_DbTable_Users is the parent class and is defined inside the Users module. Diagnostics_Model_DbTable_Diagnostics is the referenced class and is defined inside the Diagnostics module.

class Diagnostics_Model_DbTable_Diagnostics extends Zend_Db_Table_Abstract
{
    protected $_name = 'diagnostics';
    protected $_primary = 'diagnostic_id';

    protected $_referenceMap = array(
        'User' => array(
            'columns'   =>  array('diagnostic_user'),
            'refTableClass' =>  'User_Model_DbTable_Users',
            'refColumns'    =>  array('user_id')
        )
    );
}

When I now try to load the referenced Diagnostics for a User row using

$row->findDiagnostics_Model_DbTable_Diagnostics();

I get an error:

File "Diagnostics\Model\DbTable\Diagnostics.php" does not exist or class "Diagnostics_Model_DbTable_Diagnostics" was not found in the file

When I move the class Diagnostics_Model_DbTable_Diagnostics into the Users module and rename it correspondingly everthing works fine. So it seems to me as if it has something to do with classes beeing defined in different modules. None of the articles I have found during my researches could give me an answer to this. Maybe I am missing something in the main Bootstrap.php or the application.ini.

Was it helpful?

Solution

You will need to bootstrap the module. Good info: http://akrabat.com/zend-framework/bootstrapping-modules-in-zf-1-8/

I use a simple class as below:

class Diagnostics_Bootstrap extends Zend_Application_Module_Bootstrap {
     ...
}

Don't bootstrap modules you don't need, I suggest reading http://www.mwop.net/blog/234-Module-Bootstraps-in-Zend-Framework-Dos-and-Donts.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top