Reputation: 440
So I'm trying to extend the input library (CI 2.1.1), and when I call my custom save query function, its saying the function doesn't exist.
File: MY_Input.php, in the applications/libraries folder:_
class MY_Input extends CI_Input {
var $CI;
function __construct() {
parent::__construct();
$this->CI =& get_instance();
}
function save_query($query_array) {
$this->CI->db->insert('ci_query', array('query_string' => http_build_query($query_array)));
}
}
And in the controller I'm calling the function like this
$query_id = $this->input->save_query($query_array);
So what on earth am I doing wrong that it's giving me this error:_
Fatal error: Call to undefined method CI_Input::save_query() in ....
Can't see why it's not working, I even checked the user guide and according to it I guess I'm doing it right. :/
Upvotes: 2
Views: 3109
Reputation: 20753
The CI_Input
class is a core library (new thing in CI2.0.0). You will have to put your MY_Input.php
file under application/core/
to make the framework pick it up.
When in doubt, look for the original class under system/core
or system/libraries
and mirror it under application/
.
Upvotes: 2