Subversion-Projekte lars-tiefland.ci

Revision

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

Revision 2107 Revision 2242
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 - 2017, British Columbia Institute of Technology
9
 * Copyright (c) 2014 - 2018, 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 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
32
 * @copyright	Copyright (c) 2014 - 2018, 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);
701
			$this->{$qb_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
702
			$this->{$qb_key}[] = ${$qb_key};
702
			if ($this->qb_caching === TRUE)
703
			if ($this->qb_caching === TRUE)
703
			{
704
			{
704
				$this->{$qb_cache_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
705
				$this->{$qb_cache_key}[] = ${$qb_key};
705
				$this->qb_cache_exists[] = substr($qb_key, 3);
706
				$this->qb_cache_exists[] = substr($qb_key, 3);
Zeile 706... Zeile 707...
706
			}
707
			}
Zeile 832... Zeile 833...
832
			? $this->_group_get_type('')
833
			? $this->_group_get_type('')
833
			: $this->_group_get_type($type);
834
			: $this->_group_get_type($type);
Zeile 834... Zeile 835...
834
 
835
 
835
		$where_in = array(
836
		$where_in = array(
-
 
837
			'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
836
			'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
838
			'value' => NULL,
837
			'escape' => $escape
839
			'escape' => $escape
Zeile 838... Zeile 840...
838
		);
840
		);
839
 
841
 
Zeile 960... Zeile 962...
960
			if ($escape === TRUE)
962
			if ($escape === TRUE)
961
			{
963
			{
962
				$v = $this->escape_like_str($v);
964
				$v = $this->escape_like_str($v);
963
			}
965
			}
Zeile 964... Zeile 966...
964
 
966
 
965
			if ($side === 'none')
967
			switch ($side)
-
 
968
			{
966
			{
969
				case 'none':
967
				$like_statement = "{$prefix} {$k} {$not} LIKE '{$v}'";
970
					$v = "'{$v}'";
968
			}
971
					break;
969
			elseif ($side === 'before')
-
 
970
			{
972
				case 'before':
971
				$like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}'";
973
					$v = "'%{$v}'";
972
			}
974
					break;
973
			elseif ($side === 'after')
-
 
974
			{
975
				case 'after':
975
				$like_statement = "{$prefix} {$k} {$not} LIKE '{$v}%'";
976
					$v = "'{$v}%'";
976
			}
977
					break;
977
			else
978
				case 'both':
978
			{
979
				default:
-
 
980
					$v = "'%{$v}%'";
979
				$like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}%'";
981
					break;
Zeile 980... Zeile 982...
980
			}
982
			}
981
 
983
 
982
			// some platforms require an escape sequence definition for LIKE wildcards
984
			// some platforms require an escape sequence definition for LIKE wildcards
983
			if ($escape === TRUE && $this->_like_escape_str !== '')
985
			if ($escape === TRUE && $this->_like_escape_str !== '')
984
			{
986
			{
Zeile 985... Zeile 987...
985
				$like_statement .= sprintf($this->_like_escape_str, $this->_like_escape_chr);
987
				$v .= sprintf($this->_like_escape_str, $this->_like_escape_chr);
-
 
988
			}
986
			}
989
 
987
 
990
			$qb_where = array('condition' => "{$prefix} {$k} {$not} LIKE {$v}", 'value' => NULL, 'escape' => $escape);
988
			$this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape);
991
			$this->qb_where[] = $qb_where;
989
			if ($this->qb_caching === TRUE)
992
			if ($this->qb_caching === TRUE)
990
			{
993
			{
991
				$this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape);
994
				$this->qb_cache_where[] = $qb_where;
Zeile 992... Zeile 995...
992
				$this->qb_cache_exists[] = 'where';
995
				$this->qb_cache_exists[] = 'where';
Zeile 1011... Zeile 1014...
1011
 
1014
 
1012
		$this->qb_where_group_started = TRUE;
1015
		$this->qb_where_group_started = TRUE;
1013
		$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
1016
		$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
1014
		$where = array(
1017
		$where = array(
-
 
1018
			'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (',
1015
			'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (',
1019
			'value' => NULL,
1016
			'escape' => FALSE
1020
			'escape' => FALSE
Zeile 1017... Zeile 1021...
1017
		);
1021
		);
1018
 
1022
 
Zeile 1071... Zeile 1075...
1071
	public function group_end()
1075
	public function group_end()
1072
	{
1076
	{
1073
		$this->qb_where_group_started = FALSE;
1077
		$this->qb_where_group_started = FALSE;
1074
		$where = array(
1078
		$where = array(
1075
			'condition' => str_repeat(' ', $this->qb_where_group_count--).')',
1079
			'condition' => str_repeat(' ', $this->qb_where_group_count--).')',
-
 
1080
			'value' => NULL,
1076
			'escape' => FALSE
1081
			'escape' => FALSE
1077
		);
1082
		);
Zeile 1078... Zeile 1083...
1078
 
1083
 
1079
		$this->qb_where[] = $where;
1084
		$this->qb_where[] = $where;
Zeile 1403... Zeile 1408...
1403
		// ORDER BY usage is often problematic here (most notably
1408
		// ORDER BY usage is often problematic here (most notably
1404
		// on Microsoft SQL Server) and ultimately unnecessary
1409
		// on Microsoft SQL Server) and ultimately unnecessary
1405
		// for selecting COUNT(*) ...
1410
		// for selecting COUNT(*) ...
1406
		$qb_orderby       = $this->qb_orderby;
1411
		$qb_orderby       = $this->qb_orderby;
1407
		$qb_cache_orderby = $this->qb_cache_orderby;
1412
		$qb_cache_orderby = $this->qb_cache_orderby;
1408
		$this->qb_orderby = $this->qb_cache_orderby = NULL;
1413
		$this->qb_orderby = $this->qb_cache_orderby = array();
Zeile 1409... Zeile 1414...
1409
 
1414
 
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)
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)
1411
			? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
1416
			? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
Zeile 1431... Zeile 1436...
1431
	}
1436
	}
Zeile 1432... Zeile 1437...
1432
 
1437
 
Zeile 1433... Zeile 1438...
1433
	// --------------------------------------------------------------------
1438
	// --------------------------------------------------------------------
1434
 
1439
 
1435
	/**
1440
	/**
1436
	 * Get_Where
1441
	 * get_where()
1437
	 *
1442
	 *
1438
	 * Allows the where clause, limit and offset to be added directly
1443
	 * Allows the where clause, limit and offset to be added directly
1439
	 *
1444
	 *
Zeile 2208... Zeile 2213...
2208
	 * @return	string
2213
	 * @return	string
2209
	 */
2214
	 */
2210
	protected function _delete($table)
2215
	protected function _delete($table)
2211
	{
2216
	{
2212
		return 'DELETE FROM '.$table.$this->_compile_wh('qb_where')
2217
		return 'DELETE FROM '.$table.$this->_compile_wh('qb_where')
2213
			.($this->qb_limit ? ' LIMIT '.$this->qb_limit : '');
2218
			.($this->qb_limit !== FALSE ? ' LIMIT '.$this->qb_limit : '');
2214
	}
2219
	}
Zeile 2215... Zeile 2220...
2215
 
2220
 
Zeile 2216... Zeile 2221...
2216
	// --------------------------------------------------------------------
2221
	// --------------------------------------------------------------------
Zeile 2358... Zeile 2363...
2358
			.$this->_compile_group_by()
2363
			.$this->_compile_group_by()
2359
			.$this->_compile_wh('qb_having')
2364
			.$this->_compile_wh('qb_having')
2360
			.$this->_compile_order_by(); // ORDER BY
2365
			.$this->_compile_order_by(); // ORDER BY
Zeile 2361... Zeile 2366...
2361
 
2366
 
2362
		// LIMIT
2367
		// LIMIT
2363
		if ($this->qb_limit OR $this->qb_offset)
2368
		if ($this->qb_limit !== FALSE OR $this->qb_offset)
2364
		{
2369
		{
2365
			return $this->_limit($sql."\n");
2370
			return $this->_limit($sql."\n");
Zeile 2366... Zeile 2371...
2366
		}
2371
		}
Zeile 2393... Zeile 2398...
2393
				{
2398
				{
2394
					continue;
2399
					continue;
2395
				}
2400
				}
2396
				elseif ($this->{$qb_key}[$i]['escape'] === FALSE)
2401
				elseif ($this->{$qb_key}[$i]['escape'] === FALSE)
2397
				{
2402
				{
2398
					$this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition'];
2403
					$this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition'].(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
2399
					continue;
2404
					continue;
2400
				}
2405
				}
Zeile 2401... Zeile 2406...
2401
 
2406
 
2402
				// Split multiple conditions
2407
				// Split multiple conditions
Zeile 2432... Zeile 2437...
2432
 
2437
 
2433
					$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
2438
					$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
2434
						.' '.trim($matches[3]).$matches[4].$matches[5];
2439
						.' '.trim($matches[3]).$matches[4].$matches[5];
Zeile 2435... Zeile 2440...
2435
				}
2440
				}
2436
 
2441
 
Zeile 2437... Zeile 2442...
2437
				$this->{$qb_key}[$i] = implode('', $conditions);
2442
				$this->{$qb_key}[$i] = implode('', $conditions).(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
2438
			}
2443
			}
2439
 
2444