Is it even possible to do something like this in codeigniter?Is it considered a good practice in general?
Yes it is possible.
I do it all of the time, if the data is not from post I can send it to the model.
$this->load->model('some_model');
$this->some_model->some_function($var);
What data do you want to send to the model? This will help in deciding whether it is bad practice.
Ofcourse it is possible! Like Kieran showed, you can just write functions in your model class that accepts parameters.
Just keep in mind that your controller should first parse/validate these parameters, no extra validation should be included in your model. Your model should be strictly used to write to and read from the DB.
So, as a good practice, you should only pass arguments that contain actual data to be stored or used in your queries.
I usually write different functions for different WHERE cases. For example:
select($id){}
select_by_name($name){}
...
This keeps your model comprehensible. The only exception I make is in the case of limiting your result. In all my models, I have on function to select all records, with an option to pass two more variables for pagination purposes:
select_all($start=null,$limit=null){
$qry = "SELECT * FROM ...";
if($start != null) $qry .= " LIMIT ?,?";
return $this->db->query($qry,func_get_args());
}