Welcome Guest, Not a member yet? Register   Sign In
Object in session in MY_Controller clears the session completely.
#10

[eluser]pegas[/eluser]
Hi,

I think this is the place where i can also post my issue.
I have an object that contains other objects like so:


Code:
class Module {
    
    private $id_modul;
    private $orar;
    private $zi;
    private $lista_coa;    
    
    public function Module($id_modul , $orar, $zi = null, $lista_coa = '') {
        $this->id_modul = $id_modul;
        $this->orar = $orar;
        $this->zi = $zi;
        $this->lista_coa = $lista_coa;
    }
    
    function getIdModul() {
        return $this->id_modul;
    }
/* ... */

And the Schedule class (which will be stored in the $orar variable)

Code:
class Schedule {
    
    private $id_orar;
    private $schoolYear;
    
    public function Schedule($id_orar = 0, $schoolYear = null) {
        $this->id_orar = $id_orar;        
        $this->schoolYear = $schoolYear;
    }
    
    function getIdOrar(){
        return $this->id_orar;
    }
    
    function setIdOrar($id_orar){
        $this->id_orar = $id_orar;
    }
/* ... */

Now these are both container objects so I use them only to make the code clearer. Thus the classes only have set-ers and get-ers

Now I have the model class which generates me an array of Modules like so:

Code:
function loadOrCreateModules($values,$week_days){
        $modules = array();
        $this->db->select('*')->from('orar')->where('id_an', $values[0]);
        $query = $this->db->get();
        if ($query->num_rows() > 0){
            foreach ($query->result() as $row){
                $this->db->select('*')->from('modul')->where('id_orar',$row->id_orar);
                $second_query = $this->db->get();
                foreach ($second_query->result() as $row){                                        
                    $modules[] = new Module($row->id_modul, new Schedule($values[0],null),
                                                $week_days[$row->id_zi-1], $row->lista_coa);
                }                                
            }
        }else{            
            /* ... */
        }
        return $modules;
    }

And this seems to work on getting the queries and everything in place.
Except is takes about 20 seconds for the process to complete, and i initially thought I was in a infinite loop.
But then I simply returned one module object to my view and then used print_r() to look at it, for anything "busted".

Here's what was in the object:

Code:
Module Object
(
    [id_modul:Module:private] => 2
    [orar:Module:private] => Schedule Object
        (
            [benchmark] => CI_Benchmark Object
                (
                    [marker] => Array
                        (
                            [total_execution_time_start] => 0.01810100 1306970736
                            [loading_time:_base_classes_start] => 0.01812200 1306970736
                            [loading_time:_base_classes_end] => 0.66743400 1306970736
                            [controller_execution_time_( schedule / showScheduleFor )_start] => 0.66748100 1306970736
                        )

                )

            [hooks] => CI_Hooks Object
                (
                    [enabled] =>
                    [hooks] => Array
                        (
                        )

                    [in_progress] =>
                )

            [config] => CI_Config Object
                (
                    [config] => Array
                        (
                            [base_url] => http://localhost/
                            [index_page] =>
                            [uri_protocol] => AUTO
                            [url_suffix] => .do
                            [language] => romanian
                            [charset] => UTF-8
                            [enable_hooks] =>
                            [subclass_prefix] => MY_
                            [permitted_uri_chars] => a-z 0-9~%.:_\-
                            [allow_get_array] => 1
                            [enable_query_strings] =>
                            [controller_trigger] => c
                            [function_trigger] => m
                            [directory_trigger] => d
                            [log_threshold] => 2
                            [log_path] =>
                            [log_date_format] => Y-m-d H:i:s
                            [cache_path] =>
                            [encryption_key] => ONb!41@{Z)pLs]u_a:_^:5nQGx_7G-dU
                            [sess_cookie_name] => ci_session
                            [sess_expiration] => 7200
                            [sess_expire_on_close] =>
                            [sess_encrypt_cookie] =>
                            [sess_use_database] =>
                            [sess_table_name] => ci_sessions
                            [sess_match_ip] =>
/* ... */

So the object is so big that CI or my server simply quits loading this huge piece of data.
There are about 30 objects of this kind so I wouldn't blame it Smile

I want to know why is this happening. Am I leaving something activated or am I using things wrong here ?

Please help/advise,
Thanks


Messages In This Thread
Object in session in MY_Controller clears the session completely. - by El Forum - 06-01-2011, 05:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB