0
我想有類別和子類別,所以我創建了一個表類別和子類別使用Zend Framework 1
類:身份證,姓名,PAGE_ID,PARENT_ID
這是我的應用程序/模型/ Categories.php模型
<?php
class Application_Model_Categories extends Zend_Db_Table_Abstract
{
protected $_name = 'categories';
protected $_referenceMap = array(
'Pages' => array (
'columns' => 'page_id',
'refTableClass' => 'Application_Model_Pages',
'refColumns' => 'id')
);
}
這是我的應用程序/模型/ Pages.php模型
<?php
class Application_Model_Pages extends Zend_Db_Table_Abstract
{
protected $_name = "pages";
protected $_dependentTables = array('categories');
}
然後在我控制我調用模型
$pages = new Application_Model_Pages();
$find = $pages->find(2456);
$current = $find->current();
$categories = $current->findDependentRowset('Application_Model_Categories');
這是工作,但問題是,是返回所有類別,我想只有那些具有PARENT_ID = 0(如果PARENT_ID> 0他們不是大類,是 - 也許我需要一個更appropiate表名 - 小類)
我也想知道如何生成類別和子類別的數組,所以我可以返回信息過多
I'm得到調用未定義的方法Application_Model_Pages :: selectParentCategory() – handsome 2014-10-10 11:11:31