Welcome Guest, Not a member yet? Register   Sign In
$data variable not recognised until after refresh when passing array to view
#11

[eluser]gtech[/eluser]
well I was thinking you would load the api in the controller.
#12

[eluser]gtech[/eluser]
maybee I misunderstand your problem....

what does the api do.. does it talk to the database and then return xml
or does it call an external resource?
or somthing else?

what do you do with the xml?

I assumed you have a function that you call from a controller, then you get back XML .. I assumed this did not interact with the database.
#13

[eluser]rossmurphy[/eluser]
Let me explain this a bit better..

i have a my main function that takes parameters and calls the api uri and receives the results and returns the array. I am calling this function from my models and in my controllers i load the model i need and send the data to the view.

So where would the best place for my main function be? At the moment i have it as a helper.

Thanks in Advance
#14

[eluser]gtech[/eluser]
ohhhhh I getcha

[url="http://www.askaboutphp.com/beginners/50/codeigniter-extending-the-native-model-and-make-it-your-own.html"] you can either extend a model [/url] (click on link to explain)

so you can put your api function in the base model class..

if the helper works you can do that,
or you can even load a model from another model.

CI is a loose framework so you can do whichever you want.
#15

[eluser]gtech[/eluser]
oh just as an after thought, you can also autoload helpers by configuring the autoload.php in the config directory. this means you can call your 'function' from either the controller or the model without having to load the helper in every file.
#16

[eluser]rossmurphy[/eluser]
Thanks for that gtech, great advice.




Theme © iAndrew 2016 - Forum software by © MyBB