3

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?

1
  • FIXED - i knew it was something stupid :) the controller was using $this->db->findVenueInfo instead of $this->venue->findVenueInfo. Commented Apr 2, 2010 at 15:38

3 Answers 3

6

Are you sure your index.php file at the root of ur project have included bootstrap in proper place

Go to the end of the index.php file and include the bootstrap file just before including codeigniter.php.

Your index.php file should have its end lines look like this.

/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *

 * And away we go...
 *
 */

require_once APPPATH.'third_party/datamapper/bootstrap.php';

require_once BASEPATH.'core/CodeIgniter.php';
Sign up to request clarification or add additional context in comments.

Comments

3
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;
}

2 Comments

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; }
consider the first line which is not in grey background
2

I was getting a similar error and found that in 3.0 I needed to enable query_builder in application/config/database.php

$query_builder = TRUE;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.