OOP: couple of newbish questions

#1
[eluser]Unknown[/eluser]
I would be grateful for some insight:

1. I noticed two sessions being created on my website for the same user. First ones is created when user hits landing page (empty session data variable in DB table).

Once I set some session variables via helpers/libraries, a second session is created containing set variables.

Question: Should other controllers use $CI instead of $this to use the original first session without creating a second one?

IE: $CI =& get_instance(); $CI->load->('library'); $CI->library->method(); instead of $this->....

Right now different controllers use $this, and helpers/libraries use $CI.

2. How are objects created/recreated/used upon receiving HTTP requests? I.e. if in OOP, user class, a constructor fetches some user data and fills variables. How long these variables live? Is this just for current call, meaning data re-fetch on each HTTP request? Or does framework manages this in some way?

3. What are the main advantages of OOP vs procedural (I'm not to start a flame war here).
I'm pretty fluent with procedural PHP considering moving OOP. Getting weird looks when telling people I code mostly procedural (except for CI native $this and so on)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.