codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

Multiple MY_Models aren't functioning

Open Lickity opened this issue 12 years ago • 3 comments
trafficstars

When I load two different models in a controller, the methods within the first model added aren't functioning correctly.

EG

$this->load->model('currency_model');
$this->load->model('country_model');

$countries = $this->country_model->get_all();
$currencies = $this->currency_model->get_all();

Running a get_all on the country model works as it should, but running a get_all on the currency model results in nothing. Inspecting $this->db shows no query was run.

Am I missing something simple here?

Lickity avatar Apr 19 '13 04:04 Lickity

Now queries is not shown in a profiler, but you can find solution to reslove it in issues list. What about "...aren't functioning... " i thinks you got no data in currencies table

michail1982 avatar Apr 19 '13 06:04 michail1982

Data is in both tables. Inspecting $this->db (and $this->db->last_query();) when only using one model shows the expected results.

I have had the same results with any combination of models. I even created a vanilla model with two simple tables and had the same results.

It feels like something from the 2nd model is overriding something from the first model, which in turn doesn't run any queries..

Lickity avatar Apr 19 '13 06:04 Lickity

try to $this->country_model->_database->last_query(); and $this->currency_model_database->last_query();

michail1982 avatar Apr 19 '13 09:04 michail1982