Organizational Research By

Surprising Reserch Topic

Experts Most Trusted 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',
                    'refColumns'=>'id'
            )
);


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) :
?>

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

this->escape($document->docid);?></td>


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.

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

$select=$this->select()
    ->setIntegrityCheck(false)
    ->from('riba_dokumente', array('docid','bezeichnung','quelle','typ', 'pfad', 'bemerkung'))
    ->join('riba_veranstaltung', 'riba_veranstaltung.id = 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
3 views



Related Hot Questions



Government Jobs Opening


...