
I'm trying to get all the records from the database and display them in frontend.
My model look like this:
Code: Select all
class xxxModelxxx extends JModel {
var $_data;
function _buildQuery() {
$query = ' SELECT * FROM #__xxx';
return $query;
}
function getData() {
if (empty( $this->_data)){
$query = $this->_buildQuery();
$this->_data = $this->_getList( $query );
}
return $this->_data;
}
}
Code: Select all
class xxxViewxxx extends JView {
function display($tpl = null) {
$items =& $this->get( 'Data');
$this->assignRef( 'items', $items );
parent::display($tpl);
}
}
Code: Select all
<?php
defined('_JEXEC') or die('Restricted access'); ?>
<h1><?php var_dump($this->items); echo $this->items['author'];?></h1>
<h2>ala baala</h2>

Notice: Undefined index: book_name in xxx\tmpl\default.php on line 11
var_dump looks like this
Code: Select all
array(1) { [0]=> object(stdClass)#117 (20) { ["id"]=> string(1) "1" ["name"]=> string(4) "well" ["author"]=> string(11) "William well" } }