Organizational Research By

Surprising Reserch Topic

zend db using join in model

zend db using join in model  using -'zend-framework,zend-db,zend-db-table'

I want to show columns of two tabels which are in relation.

My models looks as follows:

class Application_Model_DbTable_Ribadocsveranstaltung extends Zend_Db_Table_Abstract
protected $_name = 'riba_docs';
protected $_primary = 'docid';

protected $reference_Map = array(
            'riba_veranstaltung' => array(
                        'columns' => 'riba_veranstaltung',
                    'refTableClass' => 'riba_veranstaltung',

My controller fetches all data:

$documents = new Application_Model_DbTable_Ribadocsveranstaltung();     
$this->view->ribadocs = $documents->fetchAll();

In my view I have a html table output which I built like this (snippet)

foreach($this->ribadocs as $document) :

<td class="row_<?PHP echo $i % 2;?>"><?php echo


Question: How can I get for example the column veranstaltung from my table riba_veranstaltung instead of the foreign key field veranstaltung from my table riba_docs? I've read all tutorials I could find until now, but I didn't get a satifying answer.

Ok I cheated a bit. This solution of course works:

    ->from('riba_dokumente', array('docid','bezeichnung','quelle','typ', 'pfad', 'bemerkung'))
    ->join('riba_veranstaltung', ' = riba_dokumente.veranstaltung', array('riba_veranstaltung.veranstaltung'));
    return $this->fetchAll($select);

But I still would like to know, how the state of art would be with my first try. Can somebody help?

asked Oct 19, 2015 by rolvyrf
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.