Skip to content

Commit

Permalink
Added Database::$name, the default instance name to use, fix for #2849
Browse files Browse the repository at this point in the history
  • Loading branch information
Woody Gilk committed May 6, 2010
1 parent 9785dea commit da2b5f9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions classes/kohana/database.php
Expand Up @@ -16,6 +16,11 @@ abstract class Kohana_Database {
const UPDATE = 3;
const DELETE = 4;

/**
* @var string default database instance name
*/
public static $name = 'default';

/**
* @var array Database instances
*/
Expand All @@ -30,8 +35,14 @@ abstract class Kohana_Database {
* @param array configuration parameters
* @return Database
*/
public static function instance($name = 'default', array $config = NULL)
public static function instance($name = NULL, array $config = NULL)
{
if ($name === NULL)
{
// Use the default database instance name
$name = Database::$name;
}

if ( ! isset(Database::$instances[$name]))
{
if ($config === NULL)
Expand Down Expand Up @@ -394,9 +405,6 @@ public function quote_table($value)
if (is_array($value))
{
$table =& $value[0];

// Attach table prefix to alias
$value[1] = $this->table_prefix().$value[1];
}
else
{
Expand Down

0 comments on commit da2b5f9

Please sign in to comment.