Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2008, 09:06 AM
Junior Member
 
Join Date: Apr 2008
Posts: 1
Default ambiguous result from findManyToManyRowset()?

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]
The point of the category_category table is to specify which category is the parent category.

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;
}
When I run this code, I get an error:
Quote:
Column 'type' in where clause is ambiguous
The categories which have to be shown depend on which type it is (which in turn depends on the user loading the page). If I leave out the WHERE-clause it all works fine, though I can't "hide" certain categories when needed.

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:02 AM.