CodeIgniter Forums

Full Version: [philsturgeon's REST Api] Can't access any models after REST library has been loaded. Workaround/fix?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]DevTyme[/eluser]
Hey there, if anyone has used the REST api,
https://github.com/philsturgeon/codeigniter-restserver, then I'm sure you've needed some models to process whatever you were trying to do.

How did you get your access to your models?

After the initial
Code:
$this->load->library('REST')
I cannot get access to any of my models. I can successfully load them, but any function calls result in a
Code:
PHP Fatal error: Call to a member function model_fxn_name() on a non-object in
../controllers/my_api_controller.php

..And i would load and access them like i normally would:
Code:
$this->load->model('my_model');
$this->my_model->executeFunction();

Any ideas? Anyone with this similar problem have a work around?
I have tried loading the REST library within the specific function it's calling, then call another function with my models inside the second one.. but the REST library is still within the same scope and somehow doesn't let me get any calls through.

Hrmmmm

El Forum

[eluser]Phil Sturgeon[/eluser]
You are confusing the REST server and the REST library. One serves data, the other consumes it. In the server oyu load models in the exact same way you would in any other CI app.

El Forum

[eluser]DevTyme[/eluser]
[quote author="Phil Sturgeon" date="1299215944"]You are confusing the REST server and the REST library. One serves data, the other consumes it. In the server oyu load models in the exact same way you would in any other CI app.[/quote]

I see, then I must be confused.

I see in your example controller you have it extend the REST_Controller, instead I was importing it with $this->load->library(..)..

If I rewrite my controller to match the way your example is set up, I should be good?

Thanks

El Forum

[eluser]Phil Sturgeon[/eluser]
Yep! Smile