I have this code in my model in codeigniter:
<?php
class User_model extends Model {
function User_model()
{
parent::Model();
}
function get_data()
{
$pages = false;
// Get the pages from the database using adodb if needed
$this->adodb->connect();
$recordSet = $this->adodb->execute('SELECT id, genreID, artist, albumName FROM album' );
if ( ! $recordSet )
{
log_message( 'error', 'Error connecting to the database' );
log_message( 'debug', $this->adodb->getErrorMsg());
}
else
{
unset( $this->pages );
while (!$recordSet->EOF)
{
$pages[] = array(
'id' => $recordSet->fields[0],
'genreID' => $recordSet->fields[1],
'artist' => $recordSet->fields[2],
'albumName' => $recordSet->fields[3]
);
$recordSet->MoveNext();
}
$this->pages = $pages;
}
$this->adodb->disconnect();
}
}
?>
I have this in my controller:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
//
$this->load->model('User_model');
$data['query'] = $this->User_model->get_data();
$this->load->view('welcome_message',$data);
}
}
What I cannot do is get my model results into my view. There is no result() object because I used adodb so this:
<?php foreach($query->result() as $row): ?>
<p>
<?=$row->albumName;?>
</p>
<?php endforeach; ?>
gets me an error.
What do I put in my view to get the query results of my model. I know the model works because I can echo $recordSet->fields[3]; from the model and see the album name.
Thank you for any help.
edit: I don't understand why my get_data() call in my view returns nothing.