123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- abstract class Kohana_Model_Database extends Model {
-
- public static function factory($name, $db = NULL)
- {
-
- $class = 'Model_'.$name;
- return new $class($db);
- }
-
- protected $_db;
-
- public function __construct($db = NULL)
- {
- if ($db)
- {
-
- $this->_db = $db;
- }
- elseif ( ! $this->_db)
- {
-
- $this->_db = Database::$default;
- }
- if (is_string($this->_db))
- {
-
- $this->_db = Database::instance($this->_db);
- }
- }
- }
|