Welcome Guest, Not a member yet? Register   Sign In
Problem retreiving results from database
#1

[eluser]jonhurlock[/eluser]
Hi all,

When I go to the following URL http://mydomain.com/boats/index on mysite I get the following error:
Code:
Fatal error: Class 'CI_DB_result' not found in /the-path-to-my-directory/system/database/drivers/mysql/mysql_result.php on line 27
I can insert results in to my database. However, when I go to return results from the database, the error message above appears. Any help would be appreciated. I have included the relevant pieces of code below. I can't seem to see anything wrong with the code though, is my mysql_result.php file buggered?

Best,

Jon

Controller:boats.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Boats extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->model('boats_model');
}

public function index()
{
   $data['title'] = 'Mumbles Fleet';
   $data['boats'] = $this->boats_model->get_boats();
   if (empty($data['boats']))
   {
    $this->load->view('template/header', $data);
    $this->load->view('template/footer');
   }
   $this->load->view('template/header', $data);
   $this->load->view('boat_management/show_boats', $data);
   $this->load->view('template/footer');
}
}
Model:boats_model.php
Code:
<?php
class Boats_model extends CI_Model {

public function __construct()
{
  $this->load->database();
}

public function get_boats($boat_id=FALSE)
{
  if ($boat_id == FALSE)
  {
   $query = $this->db->get('boats');
   return $query->result_array();
  }
  $query = $this->db->get_where('boats', array('id' => $boat_id));
  return $query->row_array();
}


}
View:boat_management/show_boats.php
Code:
<?php foreach ($boats as $boat): ?>
    <h2>&lt;?php echo $boat['name'] ?&gt;</h2>
    <div id="main">
        &lt;?php echo $boat['type'] ?&gt;(&lt;?php echo $boat['row_type'] ?&gt;)<br />
&lt;?php echo $boat['description'] ?&gt;
    </div>
&lt;?php endforeach ?&gt;


Messages In This Thread
Problem retreiving results from database - by El Forum - 05-17-2012, 06:39 AM
Problem retreiving results from database - by El Forum - 05-17-2012, 06:51 AM
Problem retreiving results from database - by El Forum - 05-17-2012, 06:57 AM
Problem retreiving results from database - by El Forum - 05-17-2012, 09:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB