Class Model_Database

Model_Database

extends Kohana_Model_Database
extends Model
extends Kohana_Model

Database Model base class.

package
Kohana/Database
category
Models
author
Kohana Team
copyright
(c) Kohana Team
license
https://koseven.ga/LICENSE.md


Information

This class is a transparent base class for Kohana_Model_Database

Constants

  • None

Properties

Properties

protected $_db

Default value:
NULL

Methods

public __construct([ mixed $db = NULL ] ) (defined in Kohana_Model_Database)

Loads the database.

$model = new Foo_Model($db);

Parameters

  • mixed $db = NULL - Database instance object or string

Return Values

  • void

Source Code

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);
	}
}

public static factory(string $name [, mixed $db = NULL ] ) (defined in Kohana_Model_Database)

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);

Parameters

  • string $name required - Model name
  • mixed $db = NULL - Database instance object or string

Return Values

  • Model

Source Code

public static function factory($name, $db = NULL)
{
	// Add the model prefix
	$class = 'Model_'.$name;

	return new $class($db);
}

Do you want to contribute to Koseven?

We need YOUR help!

This project is open source. What does this mean? YOU can help:
  • Found a bug? Report it on Github
  • Need a feature? Add it Here
  • Want to help? Join the Forum
Go to Github