Welcome Guest, Not a member yet? Register   Sign In
[NEWB] Do you maintain a data library?
#1

[eluser]yaniv[/eluser]
I would like to start with CI for a big project I am dealing with, there is something I don't understand I was hoping you can give me a pointer. Please note I am a CI newb, and I come from C++ (non web) environment, so please be forgiving if I talk out of my a$$ with this question...

In an intricate app, I may need to access some data from several libraries, for example user information.
I am going to have the controller call these libraries, and I can pass the data to the library with the function prototype.
However, pure OO calls for use of a data object (container) which holds the data.
When a library needs some piece of data, it looks for it in the data object, if it doesn't exists, the data object will load it from the model.

How do you do that? Can you give me a pointer?

Thanks a lot!
Y.
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

It's hard to say without knowing the purpose of the library and the structure and relationship of the data you're passing to it.

I think the simplest solution would be to make sure you pass the necessary data to your library method from the start. You could have your model pull all the data you need from wherever it resides, and pass it back to the controller. Then you can pass it straight into the library. That way, assuming your model communicates with a database, you can do it in the least number of queries/hits possible.
#3

[eluser]Otemu[/eluser]
Hi

Adding on to what TheFuzzy0ne said, whether this fits your requirements or not, it is also possible to load models directly in your libraries.
#4

[eluser]yaniv[/eluser]
I am having some trouble explaining the need for such data library.
Once I have completed the design I will come back more equipped.

Thank you two for your reply!

Y.




Theme © iAndrew 2016 - Forum software by © MyBB