Hello everyone,
I am currently reading Keith Pope's book about the zf 1.8 and trying to
implement some of the techniques and patterns into my own case. / project.
For the past few days I have been trying to get my relationships working. I
have an parent table events and each event can have an address. These
adresses I save in my table adresses.
I am trying to work a view to show de events together with the corresponding
adresses.
So in order to give as much information as possible i will walk through my
code.
In my controller i have and index action:
public function indexAction()
{
$eventModel = new EventManager_Model_Event();
$this->view->events = $eventModel->getAllEvents();
}
In my model i have:
public function getAllEvents($startDate = null, $endDate = null){
return $this->getResource('Event')->getAllEvents();
}
This will get all the events throug my Event resource:
In my event resource I have the function getAllEvents:
public function getAllEvents($startdate =null, $enddate =null,$paged=null){
$select = $this->select();
// @todo for later implementation: implement optional prameters.
// @todo functionality for ordering de resultset
$paged = true;
if(null !== $paged){
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$count = clone $select;
$count->reset(Zend_Db_Select::COLUMNS);
$count->reset(Zend_Db_Select::FROM);
$count->from(
'events',
new Zend_Db_Expr(
'COUNT(*) AS `zend_paginator_row_count`'
)
);
$adapter->setRowCount($count);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(5)
->setCurrentPageNumber((int)$paged);
return $paginator;
}
return $this->fetchAll($select);
}
And in my resources/event/Item.php i have the function:L
public function getAdres(){
$select = $this->select();
$result = $this->findDependentRowset(
'EventManager_Resource_Adres',
'adr',
$select
);
var_dump($result);
}
Which gets the adres from the adresResource.
And in my adres/item.php i have :
public function getStreet(){
return $this->getRow()->street;
}
My question:
How to get my example working? How can I access my adresses from the view?
Because for example this:
<?php var_dump($this->event->adresses);?> is returning null.
Kind regards,
J. sanders