Welcome Guest, Not a member yet? Register   Sign In
Global Variable
#11

[eluser]jupiter1031[/eluser]
I works technically but the value of q_string does not change now. So when I come in from get_year_query() it still has the initially set query. I suspected this since variable in __construct I have seen used for static variables like URLs etc.
I need a way to update the variable and keep it. Should I write it to a cookie? Not very elegant...
#12

[eluser]bubbafoley[/eluser]
constructors are used to set default values for objects. I think you might not be grasping how the application flow works. Every time you load a URL a controller runs and it's like executing a single program. When the page is done loading the program is finished executing and all the memory that was used is freed. You can't set a variable to something on page x then navigate to page y and expect your variable to be that same something. So yes you have to use a cookie or save it to a database if you want it to persist throughout the session. Or you can cache it.

You're probably better off restructuring your model though. saving queries in cookies is not a good idea.
#13

[eluser]InsiteFX[/eluser]
You can with flash_data or use sessions!

InsiteFX
#14

[eluser]jupiter1031[/eluser]
thank you all for your help. I learned a lot.




Theme © iAndrew 2016 - Forum software by © MyBB