tags:

views:

303

answers:

1

I am getting this error "Fatal error: Call to undefined method CI_DB_mysql_driver::findVenueInfo()" when I try to use one of my models.

I have a view with this anchor:

echo anchor('welcome/searchVenue/' . $row->venue_id, $row->venue);

which generates a link like: http://localhost/ci-llmg/index.php/welcome/searchVenue/1

the method called is

function searchVenue()
{
    $this->load->model('venues');
    //get venue info
    $data['info'] = $this->venues->findVenueInfo($this->uri->segment(3)); //this line generates the error

}

and the findVenueInfo function in the model (venues.php) is:

function findVenueInfo($id)
{
    $data = array();
    $this->db->where('id', $id);

    $Q = $this->db->get('venues');
    if ($Q->num_rows() > 0)
    {
        foreach ($Q->result() as $row)
        {
            $data[] = $row;
        }
    }

    $Q->free_result();
    return $data;
}

..but the result of this is Fatal error: Call to undefined method CI_DB_mysql_driver::findVenueInfo() I'm probably missing something stupid, but can't get it to work! What do you think?

A: 

function findVenueInfo($id) { $data = array(); $this->db->select()->from('venues')->where('id', $id);<----change it to

$Q = $this->db->get();<----change it to
if ($Q->num_rows() > 0)
{
    foreach ($Q->result() as $row)
    {
        $data[] = $row;
    }
}

$Q->free_result();
return $data;

}

raulb
function findVenueInfo($id) { $data = array(); $this->db->select()->from('venues')->where('id', $id);<----change it to$Q = $this->db->get();<----change it toif ($Q->num_rows() > 0){ foreach ($Q->result() as $row) { $data[] = $row; }}$Q->free_result();return $data;}
raulb
consider the first line which is not in grey background
raulb