|
|||
|
Hello people,
I've run into a bit of trouble here... let me explain I've got these two tables: Code:
// model: Category // table: category ------------------------------ id name type // model: CategoryCategory // table: category_category ------------------------------ id categoryId [references: category.id] parentId [references: category.id] I've got my Model classes all set up with reference maps, but I've run into a little snag. I'm using this function to sort all the categories into an associative array which I later use to build a menu. Code:
protected function _sortNodes($nodes)
{
$sorted = array();
foreach ($nodes as $node) {
$tmp = array(
'id' => $node->id,
'name' => $node->name,
'childs' => array()
);
$category = new Category();
$select = $category->select();
$where = $select->where("type = $this->type");
$childs = $node->findManyToManyRowset('Category', 'CategoryCategory', 'Childs', null, $where);
if ($childs->count() > 0) {
$tmp['childs'] = $this->_sortNodes($childs);
}
$sorted[] = $tmp;
}
return $sorted;
}
Quote:
I know why it happens, but I don't know how to fix it when using the 'findManyToManyRowset' method. Can anybody give me some pointers and help me out a lil' bit? Greetz, Wizz Last edited by Wizz : 04-16-2008 at 09:09 AM. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|