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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-05-2008, 11:01 PM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Default No reference from table X to table Y.

I have a simple hierarchy category layout (two layers), and in the bottom layer there is a number of channels. What I want to do is fetch all top categories (where parent = null), and then for each fetch the child categories. For each child category I need the channels in that one.

Problem is that I get an exception:
Quote:
'Zend_Db_Table_Exception' with message 'No reference from table Simple_Channel to table Simple_Channel_Category'
I take it its the reference maps thats wrong, but I can't spot the error. Can anyone help me out?

Code:

Simple_Channel_Category:
PHP Code:

class Simple_Channel_Category extends Simple_Core_Database_Table
{
    protected 
$_dependentTables = array('simple_channel''simple_channel_category');
    protected 
$_primary 'category_id'
    protected 
$_referenceMap = array(
        
'Children' => array(
            
'refTableClass' => 'Simple_Channel_Category',
            
'columns' => 'parent'
        
),
        
'Channel' => array(
            
'refTableClass' => 'simple_channel',
            
'columns' => 'category_id',
            
'refColumns' => 'id'
        
)
    );
    
    function 
getTopCategories()
    {
        return 
$this->fetchAll($this->select()->where('parent is null'));
    }

Simple_Channel:
PHP Code:
class Simple_Channel extends Simple_Core_Database_Table
{
    
// Zend_Db_Table implementation
    
protected $_name 'simple_channel';
    protected 
$_primary 'channel_id';
    protected 
$_dependentTables = array('simple_channel_category');
    protected 
$_referenceMap = array(
        
'simple_category' => array(
            
'refTableClass' => 'simple_channel_category',
            
'refTable' => 'Simple_Channel_Category',
            
'columns' => 'id'
        
)
    );

Controller:
PHP Code:
$category = new Simple_Channel_Category();

foreach(
$category->getTopCategories() as $category)
{
    echo 
$category->name.'<br />';
    foreach(
$category->findDependentRowset('simple_channel_category') as $sub)
    {
        echo 
'&nbsp;&nbsp;'$sub->category_id ' ' $sub->name ' (' get_class($sub) . ')<br />';
    
        foreach(
$sub->findDependentRowset('simple_channel') as $c)
        {
            echo 
'!!' $c->name.'<br/>';
        }
    }

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-26-2008, 05:36 AM
Junior Member
 
Join Date: Apr 2008
Posts: 10
Default

hi did you found the solution? i have the same problem
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 05:31 AM.