Changeset 3002

Show
Ignore:
Timestamp:
07/08/08 10:19:12 (1 month ago)
Author:
Shadowhand
Message:

Fixing #565, thanks Igor.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/system/libraries/Model.php

    r2035 r3002  
    1515 
    1616        /** 
    17          * Loads or sets the database instance
     17         * Loads the database instance, if the database is not already loaded
    1818         * 
    19          * @param   object   Database instance 
    2019         * @return  void 
    2120         */ 
    22         public function __construct($database = NULL
     21        public function __construct(
    2322        { 
    24                 static $db; 
    25  
    26                 if (is_object($database) AND ($database instanceof Database)) 
     23                if ( ! is_object($this->db)) 
    2724                { 
    28                         // Use the passed database instance 
    29                         $this->db = $db = $database; 
    30                 } 
    31                 else 
    32                 { 
    33                         // Load the default database if necessary 
    34                         ($db === NULL) and $db = new Database('default'); 
    35  
    36                         // Use the static database 
    37                         $this->db = $db; 
     25                        // Load the default database 
     26                        $this->db = Database::instance('default'); 
    3827                } 
    3928        }