Skip to content

Commit

Permalink
Merge branch '3.2/develop' into 3.2/master
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed Aug 24, 2012
2 parents f0944e8 + d7ce493 commit a11f464
Show file tree
Hide file tree
Showing 54 changed files with 231 additions and 210 deletions.
4 changes: 2 additions & 2 deletions classes/config/database.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

/**
* Transparent extension for the Kohana_Config_Database class
*
* @package Kohana/Database
* @category Configuration
* @author Kohana Team
* @copyright (c) 2011 Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Config_Database extends Kohana_Config_Database {}
2 changes: 1 addition & 1 deletion classes/config/database/reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @package Kohana/Database
* @category Configuration
* @author Kohana Team
* @copyright (c) 2011 Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Config_Database_Reader extends Kohana_Config_Database_Reader
Expand Down
2 changes: 1 addition & 1 deletion classes/config/database/writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @package Kohana/Database
* @category Configuration
* @author Kohana Team
* @copyright (c) 2011 Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Config_Database_Writer extends Kohana_Config_Database_Writer
Expand Down
2 changes: 1 addition & 1 deletion classes/database.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Database extends Kohana_Database {}
2 changes: 1 addition & 1 deletion classes/database/exception.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Exception extends Kohana_Database_Exception {}
2 changes: 1 addition & 1 deletion classes/database/expression.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Expression extends Kohana_Database_Expression {}
2 changes: 1 addition & 1 deletion classes/database/mysql.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_MySQL extends Kohana_Database_MySQL {}
2 changes: 1 addition & 1 deletion classes/database/mysql/result.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_MySQL_Result extends Kohana_Database_MySQL_Result {}
2 changes: 1 addition & 1 deletion classes/database/pdo.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_PDO extends Kohana_Database_PDO {}
2 changes: 1 addition & 1 deletion classes/database/query.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Query extends Kohana_Database_Query {}
2 changes: 1 addition & 1 deletion classes/database/query/builder.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Database_Query_Builder extends Kohana_Database_Query_Builder {}
2 changes: 1 addition & 1 deletion classes/database/query/builder/delete.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Query_Builder_Delete extends Kohana_Database_Query_Builder_Delete {}
2 changes: 1 addition & 1 deletion classes/database/query/builder/insert.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Query_Builder_Insert extends Kohana_Database_Query_Builder_Insert {}
2 changes: 1 addition & 1 deletion classes/database/query/builder/join.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Query_Builder_Join extends Kohana_Database_Query_Builder_Join {}
2 changes: 1 addition & 1 deletion classes/database/query/builder/select.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Query_Builder_Select extends Kohana_Database_Query_Builder_Select {}
2 changes: 1 addition & 1 deletion classes/database/query/builder/update.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Query_Builder_Update extends Kohana_Database_Query_Builder_Update {}
2 changes: 1 addition & 1 deletion classes/database/query/builder/where.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Database_Query_Builder_Where extends Kohana_Database_Query_Builder_Where {}
2 changes: 1 addition & 1 deletion classes/database/result.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Database_Result extends Kohana_Database_Result {}
2 changes: 1 addition & 1 deletion classes/database/result/cached.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class Database_Result_Cached extends Kohana_Database_Result_Cached {}
2 changes: 1 addition & 1 deletion classes/db.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

class DB extends Kohana_DB {}
6 changes: 3 additions & 3 deletions classes/kohana/config/database.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');

/**
* Backwards compatibility extension for the database writer.
*
* @package Kohana/Database
* @category Configuration
* @author Kohana Team
* @copyright (c) 2011 Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_Database extends Kohana_Config_Database_Writer
{

}
17 changes: 15 additions & 2 deletions classes/kohana/config/database/reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* @package Kohana/Database
* @category Configuration
* @author Kohana Team
* @copyright (c) 2011 Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_Database_Reader implements Kohana_Config_Reader
{
protected $_db_instance = 'default';
protected $_db_instance;

protected $_table_name = 'config';

Expand All @@ -26,6 +26,10 @@ public function __construct(array $config = NULL)
{
$this->_db_instance = $config['instance'];
}
elseif ($this->_db_instance === NULL)
{
$this->_db_instance = Database::$default;
}

if (isset($config['table_name']))
{
Expand All @@ -43,6 +47,15 @@ public function __construct(array $config = NULL)
*/
public function load($group)
{
/**
* Prevents the catch-22 scenario where the database config reader attempts to load the
* database connections details from the database.
*
* @link http://dev.kohanaframework.org/issues/4316
*/
if ($group === 'database')
return FALSE;

$query = DB::select('config_key', 'config_value')
->from($this->_table_name)
->where('group_name', '=', $group)
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/config/database/writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @package Kohana
* @category Configuration
* @author Kohana Team
* @copyright (c) 2007-2011 Kohana Team
* @copyright (c) 2007-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_Database_Writer extends Config_Database_Reader implements Kohana_Config_Writer
Expand Down
53 changes: 29 additions & 24 deletions classes/kohana/database.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Database connection wrapper/helper.
*
* You may get a database instance using `Database::instance('name')` where
* name is the [config](database/config) group.
* name is the [config](database/config) group.
*
* This class provides connection instance management via Database Drivers, as
* well as quoting, escaping and other related functions. Querys are done using
Expand All @@ -13,7 +13,7 @@
* @package Kohana/Database
* @category Base
* @author Kohana Team
* @copyright (c) 2008-2010 Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
*/
abstract class Kohana_Database {
Expand Down Expand Up @@ -45,8 +45,8 @@ abstract class Kohana_Database {
* // Create a custom configured instance
* $db = Database::instance('custom', $config);
*
* @param string instance name
* @param array configuration parameters
* @param string $name instance name
* @param array $config configuration parameters
* @return Database
*/
public static function instance($name = NULL, array $config = NULL)
Expand Down Expand Up @@ -113,6 +113,11 @@ protected function __construct($name, array $config)
// Store the config locally
$this->_config = $config;

if (empty($this->_config['table_prefix']))
{
$this->_config['table_prefix'] = '';
}

// Store the database instance
Database::$instances[$name] = $this;
}
Expand Down Expand Up @@ -177,7 +182,7 @@ public function disconnect()
* $db->set_charset('utf8');
*
* @throws Database_Exception
* @param string character set name
* @param string $charset character set name
* @return void
*/
abstract public function set_charset($charset);
Expand All @@ -191,10 +196,10 @@ abstract public function set_charset($charset);
* // Make a SELECT query and use "Model_User" for the results
* $db->query(Database::SELECT, 'SELECT * FROM users LIMIT 1', 'Model_User');
*
* @param integer Database::SELECT, Database::INSERT, etc
* @param string SQL query
* @param mixed result object class string, TRUE for stdClass, FALSE for assoc array
* @param array object construct parameters for result class
* @param integer $type Database::SELECT, Database::INSERT, etc
* @param string $sql SQL query
* @param mixed $as_object result object class string, TRUE for stdClass, FALSE for assoc array
* @param array $params object construct parameters for result class
* @return object Database_Result for SELECT queries
* @return array list (insert id, row count) for INSERT queries
* @return integer number of affected rows for all other queries
Expand All @@ -219,7 +224,7 @@ abstract public function query($type, $sql, $as_object = FALSE, array $params =
* $db->rollback();
* }
*
* @param string transaction mode
* @param string $mode transaction mode
* @return boolean
*/
abstract public function begin($mode = NULL);
Expand Down Expand Up @@ -250,7 +255,7 @@ abstract public function rollback();
* // Get the total number of records in the "users" table
* $count = $db->count_records('users');
*
* @param mixed table name string or array(query, alias)
* @param mixed $table table name string or array(query, alias)
* @return integer
*/
public function count_records($table)
Expand All @@ -267,7 +272,7 @@ public function count_records($table)
*
* $db->datatype('char');
*
* @param string SQL data type
* @param string $type SQL data type
* @return array
*/
public function datatype($type)
Expand Down Expand Up @@ -342,7 +347,7 @@ public function datatype($type)
* // Get all user-related tables
* $tables = $db->list_tables('user%');
*
* @param string table to search for
* @param string $like table to search for
* @return array
*/
abstract public function list_tables($like = NULL);
Expand All @@ -360,9 +365,9 @@ abstract public function list_tables($like = NULL);
* // Get the columns from a table that doesn't use the table prefix
* $columns = $db->list_columns('users', NULL, FALSE);
*
* @param string table to get columns from
* @param string column to search for
* @param boolean whether to add the table prefix automatically or not
* @param string $table table to get columns from
* @param string $like column to search for
* @param boolean $add_prefix whether to add the table prefix automatically or not
* @return array
*/
abstract public function list_columns($table, $like = NULL, $add_prefix = TRUE);
Expand All @@ -373,7 +378,7 @@ abstract public function list_columns($table, $like = NULL, $add_prefix = TRUE);
* // Returns: array('CHAR', '6')
* list($type, $length) = $db->_parse_type('CHAR(6)');
*
* @param string
* @param string $type
* @return array list containing the type and length, if any
*/
protected function _parse_type($type)
Expand All @@ -385,7 +390,7 @@ protected function _parse_type($type)
}

// Closing parenthesis
$close = strpos($type, ')', $open);
$close = strrpos($type, ')', $open);

// Length without parentheses
$length = substr($type, $open + 1, $close - 1 - $open);
Expand Down Expand Up @@ -420,7 +425,7 @@ public function table_prefix()
* [Database_Query] objects will be compiled and converted to a sub-query.
* All other objects will be converted using the `__toString` method.
*
* @param mixed any value to quote
* @param mixed $value any value to quote
* @return string
* @uses Database::escape
*/
Expand Down Expand Up @@ -488,7 +493,7 @@ public function quote($value)
* [Database_Query] objects will be compiled and converted to a sub-query.
* All other objects will be converted using the `__toString` method.
*
* @param mixed column name or array(column, alias)
* @param mixed $column column name or array(column, alias)
* @return string
* @uses Database::quote_identifier
* @uses Database::table_prefix
Expand Down Expand Up @@ -572,7 +577,7 @@ public function quote_column($column)
* [Database_Query] objects will be compiled and converted to a sub-query.
* All other objects will be converted using the `__toString` method.
*
* @param mixed table name or array(table, alias)
* @param mixed $table table name or array(table, alias)
* @return string
* @uses Database::quote_identifier
* @uses Database::table_prefix
Expand Down Expand Up @@ -644,7 +649,7 @@ public function quote_table($table)
* [Database_Query] objects will be compiled and converted to a sub-query.
* All other objects will be converted using the `__toString` method.
*
* @param mixed any identifier
* @param mixed $value any identifier
* @return string
*/
public function quote_identifier($value)
Expand Down Expand Up @@ -701,7 +706,7 @@ public function quote_identifier($value)
*
* $value = $db->escape('any string');
*
* @param string value to quote
* @param string $value value to quote
* @return string
*/
abstract public function escape($value);
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/database/exception.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Database exceptions.
*
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/database/expression.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php defined('SYSPATH') or die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Database expressions can be used to add unescaped SQL fragments to a
* [Database_Query_Builder] object.
Expand Down
Loading

0 comments on commit a11f464

Please sign in to comment.