[eluser]exceedstudios[/eluser]
I'm fairly new to CI and I've been having alot of trouble trying to use the MVC when trying to use database functionality. I have no problem when I do it just with the controller and view. I keep getting that blank white page when I try to load some fields from my db.
This is my code:
The Model:
Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Homemodel extends Model {
function Homemodel()
{
parent::Model();
}
function musicvideos()
{
$query = $this->db->get('clips', 4);
return $query->result();
}
}
Controller:
Code:
class Home extends Controller {
function Home()
{
parent::Controller();
}
function index()
{
$data['title'] = "Welcome";
$this->load->model('homemodel', '', TRUE);
$data['query'] = $this->homemodel->musicvideos();
$this->load->view('home_view', $data);
}
}
The View
Code:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php foreach($query->result() as $row): ?>
<?php echo $row->filename; ?><br>
<?php endforeach; ?>
</body>
</html>