Hi guys,
I'm trying to use dependent tables in ZF and I ran into a problem I
cannot solve for now.
I have two tables. One, say, with a records of files and another with
text to these files, defined by 'id' and 'language' which both form a
primary key. Reference from the "files-table" is done by id and I want
to get DependentRowset which only contains one row which I would like to
define by the "language" column. Normally I would use WHERE clause in
the select, but I am now trying to do this a ZF-way.
The code is:
// The table with file records
class TablePublicImage extends Zend_Db_Table_Abstract {
protected $_name = 'public';
protected $_primary = 'id';
protected $_dependentTables = array('TableComments');
}
// The table with those language captions
class TableComments extends Zend_Db_Table_Abstract {
protected $_name = 'comments';
protected $_primary = Array('id', 'language');
protected $_dependentTables = array('TablePublicImage');
protected $_referenceMap = array(
'PublicImage' => array(
'columns' => array('id'),
'refTableClass' => 'TablePublicImage',
'refColumns' => array('comment'),
'onDelete' => self::CASCADE,
));
}
// Then I do something like this:
$tpi = new TablePublicImage();
$tpi_data = $im->fetchAll();
foreach($tpi_data as $row)
{
$dep_rowset = $row->findTableCommentsByPublicImage();
// or $trans = $file->findDependentRowset('TableComments',
'PublicImage')
}
// and get a rowset which contains all records of captions from the
TableComments with all languages.
Is there a way to add some WHERE constraint to force the query to return
just rows WHERE language='en' (for example)?
Thanks a lot for replies,
Jan Brucek