I'm using the default framework code that was created with the Zend Framework Application tool, I added some autoloader magic so that any classes named Default_<*>_<*>
would automatically be loaded from the correct directory, in this case Default_Model_TableName
.
application/models/ProjectCategories.php:
<?php
class Default_Model_ProjectCategories extends Zend_Db_Table_Abstract {
protected $_name = 'categories';
protected $_dependentTables = array('Projects');
}
application/models/Projects.php:
<?php
class Default_Model_Projects extends Zend_Db_Table_Abstract {
protected $_name = 'projects';
protected $_referenceMap = array(
'Category' => array(
'columns' => 'cid',
'refTableClass' => 'ProjectCategories',
'refColumns' => 'id',
'onUpdate' => self::CASCADE,
'onDelete' => self::CASCADE,
)
);
}
What I am attempting to do is the following:
<?php
$categories = new Default_Model_ProjectCategories();
$category = $categories->find('1');
$category->findProjects();
At which point I get an error thrown at me that it is unable to find Projects.php, and or that the file might not have contained a class named Projects.
At that point I place Projects.php in the include path that was set up by the framework (/../library/) and the file is found, but now I lose my whole directory structure, and naming because I had to rename Default_Model_Projects
to Projects
. I am able to get everything to work if I place the file back in its original location, and change
protected $_dependentTables = array('Projects');
to
protected $_dependentTables = array('Default_Model_Projects');
but this also means that my ->findProjects()
now becomes ->findDefault_Model_Projects()
.
Is there a way to tell it that when I am looking for findProjects()
that it has to instantiate Default_Model_Projects
? Is this something that is missing from Zend Framework, or am I attempting to shoehorn something in a way that it does not belong? How have you solved this issue?