Changeset 1085

Show
Ignore:
Timestamp:
11/11/2007 01:31:18 AM (13 months ago)
Author:
Shadowhand
Message:

Fixed a bug that prevented Models from being loaded before the Kohana instance is available. Thanks Armen!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Model.php

    r1015 r1085  
    1212        /* 
    1313         * Constructor: __construct 
    14          *  Loads database into '$this->db'. 
     14         *  Loads database to $this->db. 
    1515         */ 
    1616        public function __construct() 
    1717        { 
    1818                // Load the database into the model 
    19                 $this->db = isset(Kohana::instance()->db) ? Kohana::instance()->db : new Database('default'); 
     19                if (Event::has_run('system.pre_controller')) 
     20                { 
     21                        $this->db = isset(Kohana::instance()->db) ? Kohana::instance()->db : new Database('default'); 
     22                } 
     23                else 
     24                { 
     25                        $this->db = new Database('default'); 
     26                } 
    2027        } 
    2128