Welcome Guest, Not a member yet? Register   Sign In
[philsturgeon's REST Api] Can't access any models after REST library has been loaded. Workaround/fix?
#1

[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
#2

[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.
#3

[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
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB