I have the following code in MembersMapper
public function fetchAll()
{
$resultSet = $this->getDbTable()->fetchAll();
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_Members();
$entry->setId($row->id)
->setTitle($row->title)
->setFirstName($row->first_name)
->setSurname($row->surname);
$entries[] = $entry;
}
return $entries;
}
and the Members model is like this:
protected $_id;
protected $_title;
protected $_first_name;
protected $_surname;
public function __construct(array $options = null)
{
if (is_array($options)) {
$this->setOptions($options);
}
}
public function __set($name, $value)
{
$method = 'set' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid group property');
}
$this->$method($value);
}
public function __get($name)
{
$method = 'get' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid group property');
}
return $this->$method();
}
public function setOptions(array $options)
{
$methods = get_class_methods($this);
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
$this->$method($value);
}
}
return $this;
}
public function setId($id)
{
$this->_id = (string) $id;
return $this;
}
public function getId()
{
return $this->_id;
}
public function setTitle($title)
{
$this->_title = (string) $title;
return $this;
}
public function getTitle()
{
return $this->_title;
}
public function setFirstName($first_name)
{
$this->_first_name = (string) $first_name;
return $this;
}
public function getFirstName()
{
return $this->_first_name;
}
public function setSurname($surname)
{
$this->_surname = (string) $surname;
return $this;
}
public function getSurname()
{
return $this->_surname;
}
In the controller I have this piece;
$members = new Application_Model_MembersMapper();
$this->view->entries = $members->fetchAll();
then the view index.phtml is;
<?php echo $this->form; ?>
<div id="listing">
<?php print_r($this->entries); ?>
<?php echo $this->partialLoop('partials/memberRow.phtml', $this->entries); ?>
</div><!-- end of listing -->
and finally the memberRow.phtml partial is like so;
<?php echo $this->id; ?>
When I run this I get a blank screen . A <?php print_r($this->entries); ?> displays the ff;
Array ( [0] => Application_Model_Members Object ( [_id:protected] => GH4C8825938A0B5 [_title:protected] => Mr [_first_name:protected] => Joe [_surname:protected] => Ahiable [_date_of_birth:protected] => 2010-08-09 [_gender:protected] => Male [_marital_status:protected] => Married [_mobile:protected] => 012345678 [_home_number:protected] => 020867678 [_postal_address:protected] => p.o.box 768 Tema [_address_line1:protected] => 23 Twenty Three [_address_line2:protected] => Old Street [_type_of_accommodation:protected] => Other [_other_detail:protected] => [_groups_id:protected] => [_loan_cycle_number:protected] => 0 [_date_created:protected] => 2010-09-09 01:08:51 ) )
The id is there and is populated although its got protected added to the key. Can someone help me out this has got me stuck.