Hi
I am using the ZEND FRAMEWORK
and for some reason the results from this SQL statement aren't being displayed in the table:
The query in the database model is as follows:
public function getUsersBooks($userName) {
$select = $this->select()
->from('books', array('title', 'author'))
->where('username = ?' ,$userName);
$result = $this->getAdapter()->fetchAll($select);
return $result;
The controller is as follows:
public function indexAction()
{
$this->authoriseUser();
$session = new Zend_Session_Namespace('MyNamespace');
$userName = $session->username;
$books = new Model_DbTable_Books();
$this->view->books = $books->getUsersBooks($userName);
}
And the view is as follows:
<table>
<tr>
<th>Title</th>
<th>Author</th>
</tr>
<tr>
<?php foreach($this->books as $book) : ?>
<td><?php echo $this->escape($book->title);?></td>
<td><?php echo $this->escape($book->author);?></td>
<?php endforeach; ?>
</tr>
</table>
if any one has any ideas why the results of the statement arnt being displayed it will be much apriciated