Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions system/database/DB_query_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function select($select = '*', $escape = NULL)

foreach ($select as $val)
{
$val = trim($val);
$val = trim((string)$val);

if ($val !== '')
{
Expand Down Expand Up @@ -408,10 +408,10 @@ protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX')

if ($alias === '')
{
$alias = $this->_create_alias_from_table(trim($select));
$alias = $this->_create_alias_from_table(trim((string)$select));
}

$sql = $type.'('.$this->protect_identifiers(trim($select)).') AS '.$this->escape_identifiers(trim($alias));
$sql = $type.'('.$this->protect_identifiers(trim((string)$select)).') AS '.$this->escape_identifiers(trim((string)$alias));

$this->qb_select[] = $sql;
$this->qb_no_escape[] = NULL;
Expand Down Expand Up @@ -478,7 +478,7 @@ public function from($from)
{
foreach (explode(',', $val) as $v)
{
$v = trim($v);
$v = trim((string)$v);
$this->_track_aliases($v);

$this->qb_from[] = $v = $this->protect_identifiers($v, TRUE, NULL, FALSE);
Expand All @@ -492,7 +492,7 @@ public function from($from)
}
else
{
$val = trim($val);
$val = trim((string)$val);

// Extract any aliases that might exist. We use this information
// in the protect_identifiers to know whether to add a table prefix
Expand Down Expand Up @@ -534,7 +534,7 @@ public function join($table, $cond, $type = '', $escape = NULL)
throw new InvalidArgumentException('join() expects parameter 3 to be a string, ' . gettype($type) . ' given');
}

$type = trim(strtoupper($type).' JOIN');
$type = trim((string)strtoupper($type).' JOIN');
preg_match('#^(NATURAL\s+)?((LEFT|RIGHT|FULL)\s+)?((INNER|OUTER)\s+)?JOIN$#', $type) OR $type = 'JOIN';

// Extract any aliases that might exist. We use this information
Expand Down Expand Up @@ -1217,7 +1217,7 @@ public function group_by($by, $escape = NULL)

foreach ($by as $val)
{
$val = trim($val);
$val = trim((string)$val);

if ($val !== '')
{
Expand Down Expand Up @@ -1289,7 +1289,7 @@ public function order_by($orderby, $direction = '', $escape = NULL)
throw new InvalidArgumentException('order_by() expects parameter 2 to be a string, ' . gettype($direction) . ' given');
}

$direction = strtoupper(trim($direction));
$direction = strtoupper(trim((string)$direction));

if ($direction === 'RANDOM')
{
Expand Down Expand Up @@ -1320,9 +1320,9 @@ public function order_by($orderby, $direction = '', $escape = NULL)
$qb_orderby = array();
foreach (explode(',', $orderby) as $field)
{
$qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE))
? array('field' => ltrim(substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE)
: array('field' => trim($field), 'direction' => $direction, 'escape' => TRUE);
$qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim((string)$field), $match, PREG_OFFSET_CAPTURE))
? array('field' => ltrim((string)substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE)
: array('field' => trim((string)$field), 'direction' => $direction, 'escape' => TRUE);
}
}

Expand Down Expand Up @@ -2377,7 +2377,7 @@ protected function _track_aliases($table)
$table = preg_replace('/\s+AS\s+/i', ' ', $table);

// Grab the alias
$table = trim(strrchr($table, ' '));
$table = trim((string)strrchr($table, ' '));

// Store the alias, if it doesn't already exist
if ( ! in_array($table, $this->qb_aliased_tables, TRUE))
Expand Down Expand Up @@ -2520,12 +2520,12 @@ protected function _compile_wh($qb_key)

if ( ! empty($matches[4]))
{
$this->_is_literal($matches[4]) OR $matches[4] = $this->protect_identifiers(trim($matches[4]));
$this->_is_literal($matches[4]) OR $matches[4] = $this->protect_identifiers(trim((string)$matches[4]));
$matches[4] = ' '.$matches[4];
}

$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
.' '.trim($matches[3]).$matches[4].$matches[5];
$conditions[$ci] = $matches[1].$this->protect_identifiers(trim((string)$matches[2]))
.' '.trim((string)$matches[3]).$matches[4].$matches[5];
}

$this->{$qb_key}[$i] = implode('', $conditions).(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
Expand Down Expand Up @@ -2796,7 +2796,7 @@ protected function _merge_cache()
*/
protected function _is_literal($str)
{
$str = trim($str);
$str = trim((string)$str);

if (empty($str) OR ctype_digit($str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
{
Expand Down