phpzend-frameworkzend-db-table

Zend Table Relationship not working correctly


I have two tables:

// User.php
class Model_Table_Users extends Zend_Db_Table_Abstract
{   
    protected $_name = 'users';
    protected $_primary = 'id';

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


// UserGroups.php
class Model_Table_UserGroups extends Zend_Db_Table_Abstract
{

    protected $_name = 'userGroups';

    protected $_referenceMap = array(
        'User'  => array(
            'columns'           => array('idUsers'),
            'refTableClass'     => 'users',
            'refColumns'        => array('id')
        ),
        'Group' => array(
            'columns'           => array('idGroups'),
            'refTableClass'     => 'groups',
            'refColumns'        => array('id')
        )
    );
}

Since an updated from Zend 1.10 to 1.12.*

I get the following error when I want to delete a user, for me it looks zend search not in the current folder for the UserGroups.php file.

Warning: include_once(UserGroups.php): failed to open stream: No such file or directory in /usr/share/php/Zend/Loader.php on line 134

Call Stack:
    0.0000     640960   1. {main}() /var/data/websites/test.bazinga.at/public/index.php:0
    0.0648    5056416   2. Zend_Controller_Front->dispatch() /var/data/websites/test.bazinga.at/public/index.php:166
    0.0664    5207632   3. Zend_Controller_Dispatcher_Standard->dispatch() /usr/share/php/Zend/Controller/Front.php:954
    0.0697    5411880   4. Zend_Controller_Action->dispatch() /usr/share/php/Zend/Controller/Dispatcher/Standard.php:308
    0.0698    5426312   5. Users_UserController->deleteAction() /usr/share/php/Zend/Controller/Action.php:516
    0.0704    5453504   6. Model_Users->deleteUser() */modules/users/controllers/UserController.php:417
    0.0706    5500232   7. Zend_Db_Table_Abstract->delete() */modules/users/models/Users.php:180
    0.0735    5724672   8. Zend_Db_Table_Abstract::getTableFromString() /usr/share/php/Zend/Db/Table/Abstract.php:1193
    0.0736    5724672   9. Zend_Loader::loadClass() /usr/share/php/Zend/Db/Table/Abstract.php:1594
    0.0736    5725056  10. Zend_Loader::loadFile() /usr/share/php/Zend/Loader.php:82


 Warning: include_once(): Failed opening 'UserGroups.php' for inclusion (include_path='/var/data/websites/test.bazinga.at/library:.:/usr/share/php:/usr/share/pear') in /usr/share/php/Zend/Loader.php on line 134

Call Stack:
    0.0000     640960   1. {main}() /var/data/websites/test.bazinga.at/public/index.php:0
    0.0648    5056416   2. Zend_Controller_Front->dispatch() /var/data/websites/test.bazinga.at/public/index.php:166
    0.0664    5207632   3. Zend_Controller_Dispatcher_Standard->dispatch() /usr/share/php/Zend/Controller/Front.php:954
    0.0697    5411880   4. Zend_Controller_Action->dispatch() /usr/share/php/Zend/Controller/Dispatcher/Standard.php:308
    0.0698    5426312   5. Users_UserController->deleteAction() /usr/share/php/Zend/Controller/Action.php:516
    0.0704    5453504   6. Model_Users->deleteUser() */modules/users/controllers/UserController.php:417
    0.0706    5500232   7. Zend_Db_Table_Abstract->delete() */modules/users/models/Users.php:180
    0.0735    5724672   8. Zend_Db_Table_Abstract::getTableFromString() /usr/share/php/Zend/Db/Table/Abstract.php:1193
    0.0736    5724672   9. Zend_Loader::loadClass() /usr/share/php/Zend/Db/Table/Abstract.php:1594
    0.0736    5725056  10. Zend_Loader::loadFile() /usr/share/php/Zend/Loader.php:82

I also did check the Zend changelog, but did not found anything about it.


Solution

  • Have you tried using the full name of the classes?

    // User.php
    class Model_Table_Users extends Zend_Db_Table_Abstract
    {   
        protected $_name = 'users';
        protected $_primary = 'id';
    
        protected $_dependentTables = array('Model_Table_UserGroups');
    }
    
    
    // UserGroups.php
    class Model_Table_UserGroups extends Zend_Db_Table_Abstract
    {
    
        protected $_name = 'userGroups';
    
        protected $_referenceMap = array(
            'User'  => array(
                'columns'           => array('idUsers'),
                'refTableClass'     => 'Model_Table_Users',
                'refColumns'        => array('id')
            ),
            'Group' => array(
                'columns'           => array('idGroups'),
                'refTableClass'     => 'Model_Table_Groups',
                'refColumns'        => array('id')
            )
        );
    }