0
我想要写的Joomla递归函数,得到使用类别ID使用Joomla的jmodel的分贝object.Following所有的子级,一类是我的代码,我已经写了:递归函数使用Joomla db对象
function getChildCategories($type){
$query = "SELECT id FROM #__cd_categories WHERE parent_id='$type'";
echo $query."<br/>";
$this->_db->setQuery($query);
$list = $this->_db->loadObjectList();
if ($this->_db->getErrorNum()) { echo $this->_db->stderr(); return false; }
foreach($list as $record){
$this->childCategories[]= $record->id;
echo $record->id."<br/>";
return $this->getChildCategories($record->id);
}
return true;
}
所以现在的问题是,在joomla中我们使用$ this - > _ db_setQuery方法和$ this - > _ db-> loadObjectList方法,所以在递归调用结果集时,我认为它覆盖了,我想因为对象是一样的。那么,任何人都能说出如何解决这个问题吗?如果你可以通过使用循环来解决这个问题,即使这对我也是很有帮助的。
我也认为,一旦值被分配给$ list变量,那写过就不应该是问题。所以看起来很奇怪。请告诉我是否有人能告诉我怎么做?
在此先感谢
回报可以是任何东西,在这种情况下,我节省对象的属性值,我不需要任何返回值是childCategories数组,哪里有$ list分配的问题? – Hafiz
对不起 - 我更新了我的评论 - 看看 –
是的,但你更新的代码不再是一个递归函数? – Hafiz