Skip to content

Commit a11f464

Browse files
committed
Merge branch '3.2/develop' into 3.2/master
2 parents f0944e8 + d7ce493 commit a11f464

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+231
-210
lines changed

classes/config/database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
/**
44
* Transparent extension for the Kohana_Config_Database class
55
*
66
* @package Kohana/Database
77
* @category Configuration
88
* @author Kohana Team
9-
* @copyright (c) 2011 Kohana Team
9+
* @copyright (c) 2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
1212
class Config_Database extends Kohana_Config_Database {}

classes/config/database/reader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package Kohana/Database
77
* @category Configuration
88
* @author Kohana Team
9-
* @copyright (c) 2011 Kohana Team
9+
* @copyright (c) 2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
1212
class Config_Database_Reader extends Kohana_Config_Database_Reader

classes/config/database/writer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package Kohana/Database
77
* @category Configuration
88
* @author Kohana Team
9-
* @copyright (c) 2011 Kohana Team
9+
* @copyright (c) 2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
1212
class Config_Database_Writer extends Kohana_Config_Database_Writer

classes/database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
abstract class Database extends Kohana_Database {}

classes/database/exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Exception extends Kohana_Database_Exception {}

classes/database/expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Expression extends Kohana_Database_Expression {}

classes/database/mysql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_MySQL extends Kohana_Database_MySQL {}

classes/database/mysql/result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_MySQL_Result extends Kohana_Database_MySQL_Result {}

classes/database/pdo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_PDO extends Kohana_Database_PDO {}

classes/database/query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Query extends Kohana_Database_Query {}

classes/database/query/builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
abstract class Database_Query_Builder extends Kohana_Database_Query_Builder {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Query_Builder_Delete extends Kohana_Database_Query_Builder_Delete {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Query_Builder_Insert extends Kohana_Database_Query_Builder_Insert {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Query_Builder_Join extends Kohana_Database_Query_Builder_Join {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Query_Builder_Select extends Kohana_Database_Query_Builder_Select {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Query_Builder_Update extends Kohana_Database_Query_Builder_Update {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
abstract class Database_Query_Builder_Where extends Kohana_Database_Query_Builder_Where {}

classes/database/result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
abstract class Database_Result extends Kohana_Database_Result {}

classes/database/result/cached.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class Database_Result_Cached extends Kohana_Database_Result_Cached {}

classes/db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
class DB extends Kohana_DB {}

classes/kohana/config/database.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22

33
/**
44
* Backwards compatibility extension for the database writer.
55
*
66
* @package Kohana/Database
77
* @category Configuration
88
* @author Kohana Team
9-
* @copyright (c) 2011 Kohana Team
9+
* @copyright (c) 2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
1212
class Kohana_Config_Database extends Kohana_Config_Database_Writer
1313
{
14-
14+
1515
}

classes/kohana/config/database/reader.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* @package Kohana/Database
77
* @category Configuration
88
* @author Kohana Team
9-
* @copyright (c) 2011 Kohana Team
9+
* @copyright (c) 2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
1212
class Kohana_Config_Database_Reader implements Kohana_Config_Reader
1313
{
14-
protected $_db_instance = 'default';
14+
protected $_db_instance;
1515

1616
protected $_table_name = 'config';
1717

@@ -26,6 +26,10 @@ public function __construct(array $config = NULL)
2626
{
2727
$this->_db_instance = $config['instance'];
2828
}
29+
elseif ($this->_db_instance === NULL)
30+
{
31+
$this->_db_instance = Database::$default;
32+
}
2933

3034
if (isset($config['table_name']))
3135
{
@@ -43,6 +47,15 @@ public function __construct(array $config = NULL)
4347
*/
4448
public function load($group)
4549
{
50+
/**
51+
* Prevents the catch-22 scenario where the database config reader attempts to load the
52+
* database connections details from the database.
53+
*
54+
* @link http://dev.kohanaframework.org/issues/4316
55+
*/
56+
if ($group === 'database')
57+
return FALSE;
58+
4659
$query = DB::select('config_key', 'config_value')
4760
->from($this->_table_name)
4861
->where('group_name', '=', $group)

classes/kohana/config/database/writer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package Kohana
77
* @category Configuration
88
* @author Kohana Team
9-
* @copyright (c) 2007-2011 Kohana Team
9+
* @copyright (c) 2007-2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
1212
class Kohana_Config_Database_Writer extends Config_Database_Reader implements Kohana_Config_Writer

classes/kohana/database.php

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22
/**
33
* Database connection wrapper/helper.
44
*
55
* You may get a database instance using `Database::instance('name')` where
6-
* name is the [config](database/config) group.
6+
* name is the [config](database/config) group.
77
*
88
* This class provides connection instance management via Database Drivers, as
99
* well as quoting, escaping and other related functions. Querys are done using
@@ -13,7 +13,7 @@
1313
* @package Kohana/Database
1414
* @category Base
1515
* @author Kohana Team
16-
* @copyright (c) 2008-2010 Kohana Team
16+
* @copyright (c) 2008-2012 Kohana Team
1717
* @license http://kohanaphp.com/license
1818
*/
1919
abstract class Kohana_Database {
@@ -45,8 +45,8 @@ abstract class Kohana_Database {
4545
* // Create a custom configured instance
4646
* $db = Database::instance('custom', $config);
4747
*
48-
* @param string instance name
49-
* @param array configuration parameters
48+
* @param string $name instance name
49+
* @param array $config configuration parameters
5050
* @return Database
5151
*/
5252
public static function instance($name = NULL, array $config = NULL)
@@ -113,6 +113,11 @@ protected function __construct($name, array $config)
113113
// Store the config locally
114114
$this->_config = $config;
115115

116+
if (empty($this->_config['table_prefix']))
117+
{
118+
$this->_config['table_prefix'] = '';
119+
}
120+
116121
// Store the database instance
117122
Database::$instances[$name] = $this;
118123
}
@@ -177,7 +182,7 @@ public function disconnect()
177182
* $db->set_charset('utf8');
178183
*
179184
* @throws Database_Exception
180-
* @param string character set name
185+
* @param string $charset character set name
181186
* @return void
182187
*/
183188
abstract public function set_charset($charset);
@@ -191,10 +196,10 @@ abstract public function set_charset($charset);
191196
* // Make a SELECT query and use "Model_User" for the results
192197
* $db->query(Database::SELECT, 'SELECT * FROM users LIMIT 1', 'Model_User');
193198
*
194-
* @param integer Database::SELECT, Database::INSERT, etc
195-
* @param string SQL query
196-
* @param mixed result object class string, TRUE for stdClass, FALSE for assoc array
197-
* @param array object construct parameters for result class
199+
* @param integer $type Database::SELECT, Database::INSERT, etc
200+
* @param string $sql SQL query
201+
* @param mixed $as_object result object class string, TRUE for stdClass, FALSE for assoc array
202+
* @param array $params object construct parameters for result class
198203
* @return object Database_Result for SELECT queries
199204
* @return array list (insert id, row count) for INSERT queries
200205
* @return integer number of affected rows for all other queries
@@ -219,7 +224,7 @@ abstract public function query($type, $sql, $as_object = FALSE, array $params =
219224
* $db->rollback();
220225
* }
221226
*
222-
* @param string transaction mode
227+
* @param string $mode transaction mode
223228
* @return boolean
224229
*/
225230
abstract public function begin($mode = NULL);
@@ -250,7 +255,7 @@ abstract public function rollback();
250255
* // Get the total number of records in the "users" table
251256
* $count = $db->count_records('users');
252257
*
253-
* @param mixed table name string or array(query, alias)
258+
* @param mixed $table table name string or array(query, alias)
254259
* @return integer
255260
*/
256261
public function count_records($table)
@@ -267,7 +272,7 @@ public function count_records($table)
267272
*
268273
* $db->datatype('char');
269274
*
270-
* @param string SQL data type
275+
* @param string $type SQL data type
271276
* @return array
272277
*/
273278
public function datatype($type)
@@ -342,7 +347,7 @@ public function datatype($type)
342347
* // Get all user-related tables
343348
* $tables = $db->list_tables('user%');
344349
*
345-
* @param string table to search for
350+
* @param string $like table to search for
346351
* @return array
347352
*/
348353
abstract public function list_tables($like = NULL);
@@ -360,9 +365,9 @@ abstract public function list_tables($like = NULL);
360365
* // Get the columns from a table that doesn't use the table prefix
361366
* $columns = $db->list_columns('users', NULL, FALSE);
362367
*
363-
* @param string table to get columns from
364-
* @param string column to search for
365-
* @param boolean whether to add the table prefix automatically or not
368+
* @param string $table table to get columns from
369+
* @param string $like column to search for
370+
* @param boolean $add_prefix whether to add the table prefix automatically or not
366371
* @return array
367372
*/
368373
abstract public function list_columns($table, $like = NULL, $add_prefix = TRUE);
@@ -373,7 +378,7 @@ abstract public function list_columns($table, $like = NULL, $add_prefix = TRUE);
373378
* // Returns: array('CHAR', '6')
374379
* list($type, $length) = $db->_parse_type('CHAR(6)');
375380
*
376-
* @param string
381+
* @param string $type
377382
* @return array list containing the type and length, if any
378383
*/
379384
protected function _parse_type($type)
@@ -385,7 +390,7 @@ protected function _parse_type($type)
385390
}
386391

387392
// Closing parenthesis
388-
$close = strpos($type, ')', $open);
393+
$close = strrpos($type, ')', $open);
389394

390395
// Length without parentheses
391396
$length = substr($type, $open + 1, $close - 1 - $open);
@@ -420,7 +425,7 @@ public function table_prefix()
420425
* [Database_Query] objects will be compiled and converted to a sub-query.
421426
* All other objects will be converted using the `__toString` method.
422427
*
423-
* @param mixed any value to quote
428+
* @param mixed $value any value to quote
424429
* @return string
425430
* @uses Database::escape
426431
*/
@@ -488,7 +493,7 @@ public function quote($value)
488493
* [Database_Query] objects will be compiled and converted to a sub-query.
489494
* All other objects will be converted using the `__toString` method.
490495
*
491-
* @param mixed column name or array(column, alias)
496+
* @param mixed $column column name or array(column, alias)
492497
* @return string
493498
* @uses Database::quote_identifier
494499
* @uses Database::table_prefix
@@ -572,7 +577,7 @@ public function quote_column($column)
572577
* [Database_Query] objects will be compiled and converted to a sub-query.
573578
* All other objects will be converted using the `__toString` method.
574579
*
575-
* @param mixed table name or array(table, alias)
580+
* @param mixed $table table name or array(table, alias)
576581
* @return string
577582
* @uses Database::quote_identifier
578583
* @uses Database::table_prefix
@@ -644,7 +649,7 @@ public function quote_table($table)
644649
* [Database_Query] objects will be compiled and converted to a sub-query.
645650
* All other objects will be converted using the `__toString` method.
646651
*
647-
* @param mixed any identifier
652+
* @param mixed $value any identifier
648653
* @return string
649654
*/
650655
public function quote_identifier($value)
@@ -701,7 +706,7 @@ public function quote_identifier($value)
701706
*
702707
* $value = $db->escape('any string');
703708
*
704-
* @param string value to quote
709+
* @param string $value value to quote
705710
* @return string
706711
*/
707712
abstract public function escape($value);

classes/kohana/database/exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22
/**
33
* Database exceptions.
44
*

classes/kohana/database/expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php defined('SYSPATH') or die('No direct script access.');
1+
<?php defined('SYSPATH') OR die('No direct script access.');
22
/**
33
* Database expressions can be used to add unescaped SQL fragments to a
44
* [Database_Query_Builder] object.

0 commit comments

Comments
 (0)