1

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

enter image description here

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.

1
  • Probably desirable to move your solution to an Answer and add your request for more info to a Comment, either here or on that Answer. :D Commented Oct 19, 2015 at 11:17

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.