Page 1 of 1

Zend_Db and dependentRows

Posted: Sun Aug 19, 2007 11:21 am
by jamiel
Hey 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.

Code: Select all

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.