This class is a transparent base class for Model_Database and should not be accessed directly.
Database Model base class.
Class declared in MODPATH/database/classes/Kohana/Model/Database.php on line 11.
$_dbNULL
Loads the database.
$model = new Foo_Model($db);
mixed
$db
= NULL - Database instance object or stringvoid
public function __construct($db = NULL)
{
if ($db)
{
// Set the instance or name
$this->_db = $db;
}
elseif ( ! $this->_db)
{
// Use the default name
$this->_db = Database::$default;
}
if (is_string($this->_db))
{
// Load the database
$this->_db = Database::instance($this->_db);
}
}
Create a new model instance. A Database instance or configuration group name can be passed to the model. If no database is defined, the "default" database group will be used.
$model = Model::factory($name);
string
$name
required - Model namemixed
$db
= NULL - Database instance object or stringModel
public static function factory($name, $db = NULL)
{
// Add the model prefix
$class = 'Model_'.$name;
return new $class($db);
}