Welcome Guest, Not a member yet? Register   Sign In
Models stepping on each other?
#1

[eluser]Unknown[/eluser]
I've got a question about models that are loaded in by the same controller.

I have an e-commerce application with multiple stores. Say Customer A is purchasing from one store that loads in a customer model. If Customer B is on the site and loads up another request that uses the customer model, will Customer B potentially use the same customer model that Customer A pulled up? The different stores have different implementations of some customer data, so I want to make sure Store X's customer data is not intermingled with Store Y's customer data.

How can I best ensure that Customer B doesn't use Customer A's customer model that is currently in memory in cases of high-traffic?

Should I use a factory pattern since CI has Singleton implementations of models and controllers (please shed some light and correct me if I am wrong?) I have not used a factory pattern, before by the way.

Thanks in advance.
#2

[eluser]danmontgomery[/eluser]
What you're describing is not in any way possible.
#3

[eluser]tomdelonge[/eluser]
That's not quite what singleton is. In any case, each model is instantiated as a separate object. In every request, everything is new. The models treat everything with customer a and customer b the same. If they need something treated differently, then you have to use sessions or something to store the extra data. What you're suggesting, like noctrum said, is not really a problem.




Theme © iAndrew 2016 - Forum software by © MyBB