Image is a parent of ImageGallery; ImageGallery is a dependent of Image.

You need to use findParentRow('Image').

Regards,
Bill Karwin

> -----Original Message-----
> From: Jamie Learmonth [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, August 19, 2007 6:01 AM
> To: [email protected]
> Subject: [fw-general] Dependant Rowsets in Zend_Db
> 
> Hi all,
> 
> I am trying to use the dependantRowSet functionality of 
> Zend_Db in order to retrieve a Rowset from a second table 
> liked by a foreign key constraint.
> 
> Below is some test code which I have knocked up to achieve 
> this, but Zend_Db is throwing an Exception of 'No reference 
> from table Image to table ImageGallery' . This seems like 
> quite a trivial operation so I'm sure I have just missed 
> something elementary.
> 
> class Image extends Zend_Db_Table_Abstract
>     {
>         protected $_name = 'dbname.image';
>         protected $_primary = 'id';
>         protected $_dependentTables = array('ImageGallery');   
>     }
> 
> class ImageGallery extends Zend_Db_Table_Abstract
>     {
>         protected $_name         = 'dbname.image_gallery';
>         protected $_primary      = 'id';
>         protected $_referenceMap = array(
>             'Image' => array(
>                 'columns' => 'image_id',
>                 'refTableClass' => 'Image',
>                 'refColumns' => 'id'),
>             'Section' => array(
>                 'columns' => 'section_id',
>                 'refTableClass' => 'Section',
>                 'refColumns' => 'id'),
>             'Subsection' => array(
>                 'columns' => 'subsection_id',
>                 'refTableClass' => 'Subsection',
>                 'refColumns' => 'id')
>             );
> 
>         public static function getSectionImageCount($sectionName)
>         {
>             $gallery = new ImageGallery();
>             $galleryImageRs = $gallery->find(1);
>             $galleryImage = $galleryImageRs->current();
>             
> Zend_Debug::dump($galleryImage->findDependentRowset('Image'));
>         }
>     }
> 
> Exception occurs when calling getSectionImageCount() from my 
> controller.
> 
> Kind Regards,
> 
> Jamie Learmonth
> Lead Developer
> 
> [EMAIL PROTECTED]
> Boxlight Media Ltd.
> 
> 

Reply via email to