Subversion-Projekte lars-tiefland.ci

Revision

Revision 2242 | Revision 2257 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2242 Revision 2254
Zeile 4... Zeile 4...
4
 *
4
 *
5
 * An open source application development framework for PHP
5
 * An open source application development framework for PHP
6
 *
6
 *
7
 * This content is released under the MIT License (MIT)
7
 * This content is released under the MIT License (MIT)
8
 *
8
 *
9
 * Copyright (c) 2014 - 2018, British Columbia Institute of Technology
9
 * Copyright (c) 2014 - 2017, British Columbia Institute of Technology
10
 *
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Zeile 27... Zeile 27...
27
 * THE SOFTWARE.
27
 * THE SOFTWARE.
28
 *
28
 *
29
 * @package	CodeIgniter
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
 * @copyright	Copyright (c) 2014 - 2018, British Columbia Institute of Technology (http://bcit.ca/)
32
 * @copyright	Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
33
 * @license	http://opensource.org/licenses/MIT	MIT License
33
 * @license	http://opensource.org/licenses/MIT	MIT License
34
 * @link	https://codeigniter.com
34
 * @link	https://codeigniter.com
35
 * @since	Version 1.0.0
35
 * @since	Version 1.0.0
36
 * @filesource
36
 * @filesource
37
 */
37
 */
Zeile 678... Zeile 678...
678
 
678
 
679
			if ($v !== NULL)
679
			if ($v !== NULL)
680
			{
680
			{
681
				if ($escape === TRUE)
681
				if ($escape === TRUE)
682
				{
682
				{
683
					$v = $this->escape($v);
683
					$v = ' '.$this->escape($v);
Zeile 684... Zeile 684...
684
				}
684
				}
685
 
685
 
686
				if ( ! $this->_has_operator($k))
686
				if ( ! $this->_has_operator($k))
Zeile 696... Zeile 696...
696
			elseif (preg_match('/\s*(!?=|<>|\sIS(?:\s+NOT)?\s)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
696
			elseif (preg_match('/\s*(!?=|<>|\sIS(?:\s+NOT)?\s)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
697
			{
697
			{
698
				$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
698
				$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
699
			}
699
			}
Zeile 700... Zeile 700...
700
 
700
 
701
			${$qb_key} = array('condition' => $prefix.$k, 'value' => $v, 'escape' => $escape);
-
 
702
			$this->{$qb_key}[] = ${$qb_key};
701
			$this->{$qb_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
703
			if ($this->qb_caching === TRUE)
702
			if ($this->qb_caching === TRUE)
704
			{
703
			{
705
				$this->{$qb_cache_key}[] = ${$qb_key};
704
				$this->{$qb_cache_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
706
				$this->qb_cache_exists[] = substr($qb_key, 3);
705
				$this->qb_cache_exists[] = substr($qb_key, 3);
Zeile 707... Zeile 706...
707
			}
706
			}
Zeile 833... Zeile 832...
833
			? $this->_group_get_type('')
832
			? $this->_group_get_type('')
834
			: $this->_group_get_type($type);
833
			: $this->_group_get_type($type);
Zeile 835... Zeile 834...
835
 
834
 
836
		$where_in = array(
835
		$where_in = array(
837
			'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
-
 
838
			'value' => NULL,
836
			'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
839
			'escape' => $escape
837
			'escape' => $escape
Zeile 840... Zeile 838...
840
		);
838
		);
841
 
839
 
Zeile 962... Zeile 960...
962
			if ($escape === TRUE)
960
			if ($escape === TRUE)
963
			{
961
			{
964
				$v = $this->escape_like_str($v);
962
				$v = $this->escape_like_str($v);
965
			}
963
			}
Zeile 966... Zeile 964...
966
 
964
 
967
			switch ($side)
965
			if ($side === 'none')
968
			{
-
 
969
				case 'none':
966
			{
970
					$v = "'{$v}'";
967
				$like_statement = "{$prefix} {$k} {$not} LIKE '{$v}'";
971
					break;
968
			}
-
 
969
			elseif ($side === 'before')
972
				case 'before':
970
			{
973
					$v = "'%{$v}'";
971
				$like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}'";
974
					break;
972
			}
-
 
973
			elseif ($side === 'after')
975
				case 'after':
974
			{
976
					$v = "'{$v}%'";
975
				$like_statement = "{$prefix} {$k} {$not} LIKE '{$v}%'";
977
					break;
976
			}
978
				case 'both':
977
			else
979
				default:
978
			{
980
					$v = "'%{$v}%'";
-
 
981
					break;
979
				$like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}%'";
Zeile 982... Zeile 980...
982
			}
980
			}
983
 
981
 
984
			// some platforms require an escape sequence definition for LIKE wildcards
982
			// some platforms require an escape sequence definition for LIKE wildcards
985
			if ($escape === TRUE && $this->_like_escape_str !== '')
983
			if ($escape === TRUE && $this->_like_escape_str !== '')
986
			{
984
			{
Zeile 987... Zeile 985...
987
				$v .= sprintf($this->_like_escape_str, $this->_like_escape_chr);
985
				$like_statement .= sprintf($this->_like_escape_str, $this->_like_escape_chr);
988
			}
-
 
989
 
986
			}
990
			$qb_where = array('condition' => "{$prefix} {$k} {$not} LIKE {$v}", 'value' => NULL, 'escape' => $escape);
987
 
991
			$this->qb_where[] = $qb_where;
988
			$this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape);
992
			if ($this->qb_caching === TRUE)
989
			if ($this->qb_caching === TRUE)
993
			{
990
			{
994
				$this->qb_cache_where[] = $qb_where;
991
				$this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape);
Zeile 995... Zeile 992...
995
				$this->qb_cache_exists[] = 'where';
992
				$this->qb_cache_exists[] = 'where';
Zeile 1014... Zeile 1011...
1014
 
1011
 
1015
		$this->qb_where_group_started = TRUE;
1012
		$this->qb_where_group_started = TRUE;
1016
		$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
1013
		$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
1017
		$where = array(
1014
		$where = array(
1018
			'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (',
-
 
1019
			'value' => NULL,
1015
			'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (',
1020
			'escape' => FALSE
1016
			'escape' => FALSE
Zeile 1021... Zeile 1017...
1021
		);
1017
		);
1022
 
1018
 
Zeile 1075... Zeile 1071...
1075
	public function group_end()
1071
	public function group_end()
1076
	{
1072
	{
1077
		$this->qb_where_group_started = FALSE;
1073
		$this->qb_where_group_started = FALSE;
1078
		$where = array(
1074
		$where = array(
1079
			'condition' => str_repeat(' ', $this->qb_where_group_count--).')',
1075
			'condition' => str_repeat(' ', $this->qb_where_group_count--).')',
1080
			'value' => NULL,
-
 
1081
			'escape' => FALSE
1076
			'escape' => FALSE
1082
		);
1077
		);
Zeile 1083... Zeile 1078...
1083
 
1078
 
1084
		$this->qb_where[] = $where;
1079
		$this->qb_where[] = $where;
Zeile 1408... Zeile 1403...
1408
		// ORDER BY usage is often problematic here (most notably
1403
		// ORDER BY usage is often problematic here (most notably
1409
		// on Microsoft SQL Server) and ultimately unnecessary
1404
		// on Microsoft SQL Server) and ultimately unnecessary
1410
		// for selecting COUNT(*) ...
1405
		// for selecting COUNT(*) ...
1411
		$qb_orderby       = $this->qb_orderby;
1406
		$qb_orderby       = $this->qb_orderby;
1412
		$qb_cache_orderby = $this->qb_cache_orderby;
1407
		$qb_cache_orderby = $this->qb_cache_orderby;
1413
		$this->qb_orderby = $this->qb_cache_orderby = array();
1408
		$this->qb_orderby = $this->qb_cache_orderby = NULL;
Zeile 1414... Zeile 1409...
1414
 
1409
 
1415
		$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset)
1410
		$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset)
1416
			? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
1411
			? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
Zeile 1436... Zeile 1431...
1436
	}
1431
	}
Zeile 1437... Zeile 1432...
1437
 
1432
 
Zeile 1438... Zeile 1433...
1438
	// --------------------------------------------------------------------
1433
	// --------------------------------------------------------------------
1439
 
1434
 
1440
	/**
1435
	/**
1441
	 * get_where()
1436
	 * Get_Where
1442
	 *
1437
	 *
1443
	 * Allows the where clause, limit and offset to be added directly
1438
	 * Allows the where clause, limit and offset to be added directly
1444
	 *
1439
	 *
Zeile 2213... Zeile 2208...
2213
	 * @return	string
2208
	 * @return	string
2214
	 */
2209
	 */
2215
	protected function _delete($table)
2210
	protected function _delete($table)
2216
	{
2211
	{
2217
		return 'DELETE FROM '.$table.$this->_compile_wh('qb_where')
2212
		return 'DELETE FROM '.$table.$this->_compile_wh('qb_where')
2218
			.($this->qb_limit !== FALSE ? ' LIMIT '.$this->qb_limit : '');
2213
			.($this->qb_limit ? ' LIMIT '.$this->qb_limit : '');
2219
	}
2214
	}
Zeile 2220... Zeile 2215...
2220
 
2215
 
Zeile 2221... Zeile 2216...
2221
	// --------------------------------------------------------------------
2216
	// --------------------------------------------------------------------
Zeile 2363... Zeile 2358...
2363
			.$this->_compile_group_by()
2358
			.$this->_compile_group_by()
2364
			.$this->_compile_wh('qb_having')
2359
			.$this->_compile_wh('qb_having')
2365
			.$this->_compile_order_by(); // ORDER BY
2360
			.$this->_compile_order_by(); // ORDER BY
Zeile 2366... Zeile 2361...
2366
 
2361
 
2367
		// LIMIT
2362
		// LIMIT
2368
		if ($this->qb_limit !== FALSE OR $this->qb_offset)
2363
		if ($this->qb_limit OR $this->qb_offset)
2369
		{
2364
		{
2370
			return $this->_limit($sql."\n");
2365
			return $this->_limit($sql."\n");
Zeile 2371... Zeile 2366...
2371
		}
2366
		}
Zeile 2398... Zeile 2393...
2398
				{
2393
				{
2399
					continue;
2394
					continue;
2400
				}
2395
				}
2401
				elseif ($this->{$qb_key}[$i]['escape'] === FALSE)
2396
				elseif ($this->{$qb_key}[$i]['escape'] === FALSE)
2402
				{
2397
				{
2403
					$this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition'].(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
2398
					$this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition'];
2404
					continue;
2399
					continue;
2405
				}
2400
				}
Zeile 2406... Zeile 2401...
2406
 
2401
 
2407
				// Split multiple conditions
2402
				// Split multiple conditions
Zeile 2437... Zeile 2432...
2437
 
2432
 
2438
					$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
2433
					$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
2439
						.' '.trim($matches[3]).$matches[4].$matches[5];
2434
						.' '.trim($matches[3]).$matches[4].$matches[5];
Zeile 2440... Zeile 2435...
2440
				}
2435
				}
2441
 
2436
 
Zeile 2442... Zeile 2437...
2442
				$this->{$qb_key}[$i] = implode('', $conditions).(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
2437
				$this->{$qb_key}[$i] = implode('', $conditions);
2443
			}
2438
			}
2444
 
2439