Skip to content

Commit 99e602d

Browse files
author
Root
committed
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
2 parents 35ac46d + f33e2ff commit 99e602d

23 files changed

Lines changed: 226 additions & 99 deletions

File tree

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ env:
1313
- DB=pdo/sqlite
1414

1515
before_script:
16-
- pyrus channel-discover pear.php-tools.net
17-
- pyrus install http://pear.php-tools.net/get/vfsStream-0.11.2.tgz
18-
- phpenv rehash
16+
- curl -s http://getcomposer.org/installer | php
17+
- php composer.phar install
1918
- sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi"
2019
- sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi"
2120
- sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi"
@@ -24,5 +23,4 @@ script: phpunit --configuration tests/travis/$DB.phpunit.xml
2423

2524
branches:
2625
only:
27-
- develop
28-
- master
26+
- develop

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"mikey179/vfsStream": "*"
4+
}
5+
}

system/core/Lang.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ public function __construct()
6565
/**
6666
* Load a language file
6767
*
68-
* @param mixed the name of the language file to be loaded. Can be an array
68+
* @param mixed the name of the language file to be loaded
6969
* @param string the language (english, etc.)
7070
* @param bool return loaded array of translations
7171
* @param bool add suffix to $langfile
7272
* @param string alternative path to look for language file
7373
* @return mixed
7474
*/
75-
public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
75+
public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
7676
{
7777
$langfile = str_replace('.php', '', $langfile);
7878

system/database/DB.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ function &DB($params = '', $query_builder_override = NULL)
118118
{
119119
$query_builder = $query_builder_override;
120120
}
121+
// Backwards compatibility work-around for keeping the
122+
// $active_record config variable working. Should be
123+
// removed in v3.1
124+
elseif ( ! isset($query_builder) && isset($active_record))
125+
{
126+
$query_builder = $active_record;
127+
}
121128

122129
require_once(BASEPATH.'database/DB_driver.php');
123130

@@ -159,4 +166,4 @@ class CI_DB extends CI_DB_driver { }
159166
}
160167

161168
/* End of file DB.php */
162-
/* Location: ./system/database/DB.php */
169+
/* Location: ./system/database/DB.php */

system/database/DB_driver.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,23 +1404,6 @@ protected function _reset_select()
14041404
{
14051405
}
14061406

1407-
// --------------------------------------------------------------------
1408-
1409-
/**
1410-
* Destructor
1411-
*
1412-
* Closes the database connection, if needed.
1413-
*
1414-
* @return void
1415-
*/
1416-
public function __destruct()
1417-
{
1418-
if ( ! $this->pconnect)
1419-
{
1420-
$this->close();
1421-
}
1422-
}
1423-
14241407
}
14251408

14261409
/* End of file DB_driver.php */

system/database/DB_query_builder.php

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX')
211211
$alias = $this->_create_alias_from_table(trim($select));
212212
}
213213

214-
$sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias));
215-
214+
$sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->escape_identifiers(trim($alias));
215+
216216
$this->qb_select[] = $sql;
217217
$this->qb_no_escape[] = NULL;
218218

@@ -256,7 +256,7 @@ protected function _create_alias_from_table($item)
256256
*/
257257
public function distinct($val = TRUE)
258258
{
259-
$this->qb_distinct = (is_bool($val)) ? $val : TRUE;
259+
$this->qb_distinct = is_bool($val) ? $val : TRUE;
260260
return $this;
261261
}
262262

@@ -272,7 +272,7 @@ public function distinct($val = TRUE)
272272
*/
273273
public function from($from)
274274
{
275-
foreach ((array)$from as $val)
275+
foreach ((array) $from as $val)
276276
{
277277
if (strpos($val, ',') !== FALSE)
278278
{
@@ -1111,6 +1111,8 @@ public function get($table = '', $limit = null, $offset = null)
11111111
return $result;
11121112
}
11131113

1114+
// --------------------------------------------------------------------
1115+
11141116
/**
11151117
* "Count All Results" query
11161118
*
@@ -1139,6 +1141,7 @@ public function count_all_results($table = '')
11391141
$row = $result->row();
11401142
return (int) $row->numrows;
11411143
}
1144+
11421145
// --------------------------------------------------------------------
11431146

11441147
/**
@@ -1401,16 +1404,13 @@ protected function _validate_insert($table = '')
14011404
return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
14021405
}
14031406

1404-
if ($table == '')
1407+
if ($table != '')
14051408
{
1406-
if ( ! isset($this->qb_from[0]))
1407-
{
1408-
return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
1409-
}
1409+
$this->qb_from[0] = $table;
14101410
}
1411-
else
1411+
elseif ( ! isset($this->qb_from[0]))
14121412
{
1413-
$this->qb_from[0] = $table;
1413+
return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
14141414
}
14151415

14161416
return TRUE;
@@ -1600,16 +1600,13 @@ protected function _validate_update($table = '')
16001600
return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
16011601
}
16021602

1603-
if ($table == '')
1603+
if ($table != '')
16041604
{
1605-
if ( ! isset($this->qb_from[0]))
1606-
{
1607-
return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
1608-
}
1605+
$this->qb_from[0] = $table;
16091606
}
1610-
else
1607+
elseif ( ! isset($this->qb_from[0]))
16111608
{
1612-
$this->qb_from[0] = $table;
1609+
return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
16131610
}
16141611

16151612
return TRUE;
@@ -1696,15 +1693,11 @@ public function set_update_batch($key, $index = '', $escape = TRUE)
16961693
{
16971694
$index_set = TRUE;
16981695
}
1699-
else
1700-
{
1701-
$not[] = $k.'-'.$v;
1702-
}
17031696

17041697
$clean[$this->protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
17051698
}
17061699

1707-
if ($index_set == FALSE)
1700+
if ($index_set === FALSE)
17081701
{
17091702
return $this->display_error('db_batch_missing_index');
17101703
}
@@ -2102,7 +2095,7 @@ protected function _compile_select($select_override = FALSE)
21022095
* @param object
21032096
* @return array
21042097
*/
2105-
public function _object_to_array($object)
2098+
protected function _object_to_array($object)
21062099
{
21072100
if ( ! is_object($object))
21082101
{
@@ -2132,7 +2125,7 @@ public function _object_to_array($object)
21322125
* @param object
21332126
* @return array
21342127
*/
2135-
public function _object_to_array_batch($object)
2128+
protected function _object_to_array_batch($object)
21362129
{
21372130
if ( ! is_object($object))
21382131
{

system/database/DB_result.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public function custom_row_object($n, $type)
242242
$result = $this->custom_result_object($type);
243243
if (count($result) === 0)
244244
{
245-
return $result;
245+
return NULL;
246246
}
247247

248248
if ($n != $this->current_row && isset($result[$n]))
@@ -253,6 +253,8 @@ public function custom_row_object($n, $type)
253253
return $result[$this->current_row];
254254
}
255255

256+
// --------------------------------------------------------------------
257+
256258
/**
257259
* Returns a single result row - object version
258260
*
@@ -263,7 +265,7 @@ public function row_object($n = 0)
263265
$result = $this->result_object();
264266
if (count($result) === 0)
265267
{
266-
return $result;
268+
return NULL;
267269
}
268270

269271
if ($n != $this->current_row && isset($result[$n]))
@@ -286,7 +288,7 @@ public function row_array($n = 0)
286288
$result = $this->result_array();
287289
if (count($result) === 0)
288290
{
289-
return $result;
291+
return NULL;
290292
}
291293

292294
if ($n != $this->current_row && isset($result[$n]))
@@ -307,7 +309,7 @@ public function row_array($n = 0)
307309
public function first_row($type = 'object')
308310
{
309311
$result = $this->result($type);
310-
return (count($result) === 0) ? $result : $result[0];
312+
return (count($result) === 0) ? NULL : $result[0];
311313
}
312314

313315
// --------------------------------------------------------------------
@@ -320,7 +322,7 @@ public function first_row($type = 'object')
320322
public function last_row($type = 'object')
321323
{
322324
$result = $this->result($type);
323-
return (count($result) === 0) ? $result : $result[count($result) - 1];
325+
return (count($result) === 0) ? NULL : $result[count($result) - 1];
324326
}
325327

326328
// --------------------------------------------------------------------
@@ -335,7 +337,7 @@ public function next_row($type = 'object')
335337
$result = $this->result($type);
336338
if (count($result) === 0)
337339
{
338-
return $result;
340+
return NULL;
339341
}
340342

341343
if (isset($result[$this->current_row + 1]))
@@ -358,7 +360,7 @@ public function previous_row($type = 'object')
358360
$result = $this->result($type);
359361
if (count($result) === 0)
360362
{
361-
return $result;
363+
return NULL;
362364
}
363365

364366
if (isset($result[$this->current_row - 1]))

system/database/DB_utility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosur
212212
$out = rtrim($out).$newline;
213213

214214
// Next blast through the result array and build out the rows
215-
foreach ($query->result_array() as $row)
215+
while ($row = $query->unbuffered_row('array'))
216216
{
217217
foreach ($row as $item)
218218
{
@@ -258,7 +258,7 @@ public function xml_from_result($query, $params = array())
258258

259259
// Generate the result
260260
$xml = '<'.$root.'>'.$newline;
261-
foreach ($query->result_array() as $row)
261+
while ($row = $query->unbuffered_row())
262262
{
263263
$xml .= $tab.'<'.$element.'>'.$newline;
264264
foreach ($row as $key => $val)

system/database/drivers/mysql/mysql_driver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CI_DB_mysql_driver extends CI_DB {
4747

4848
// clause and character used for LIKE escape sequences - not used in MySQL
4949
protected $_like_escape_str = '';
50-
protected $_like_escape_chr = '';
50+
protected $_like_escape_chr = '\\';
5151

5252
/**
5353
* The syntax to count rows is slightly different across different
@@ -291,7 +291,9 @@ public function escape_str($str, $like = FALSE)
291291
// escape LIKE condition wildcards
292292
if ($like === TRUE)
293293
{
294-
return str_replace(array('%', '_'), array('\\%', '\\_'), $str);
294+
return str_replace(array($this->_like_escape_chr, '%', '_'),
295+
array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
296+
$str);
295297
}
296298

297299
return $str;

system/database/drivers/mysqli/mysqli_driver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CI_DB_mysqli_driver extends CI_DB {
4747

4848
// clause and character used for LIKE escape sequences - not used in MySQL
4949
protected $_like_escape_str = '';
50-
protected $_like_escape_chr = '';
50+
protected $_like_escape_chr = '\\';
5151

5252
/**
5353
* The syntax to count rows is slightly different across different
@@ -291,7 +291,9 @@ public function escape_str($str, $like = FALSE)
291291
// escape LIKE condition wildcards
292292
if ($like === TRUE)
293293
{
294-
return str_replace(array('%', '_'), array('\\%', '\\_'), $str);
294+
return str_replace(array($this->_like_escape_chr, '%', '_'),
295+
array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
296+
$str);
295297
}
296298

297299
return $str;

0 commit comments

Comments
 (0)