Subversion-Projekte lars-tiefland.ci

Revision

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

Revision 1257 Revision 2049
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 - 2016, 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 - 2016, 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 148... Zeile 148...
148
	 * @var	array
148
	 * @var	array
149
	 */
149
	 */
150
	protected $qb_set			= array();
150
	protected $qb_set			= array();
Zeile 151... Zeile 151...
151
 
151
 
-
 
152
	/**
-
 
153
	 * QB data set for update_batch()
-
 
154
	 *
-
 
155
	 * @var	array
-
 
156
	 */
-
 
157
	protected $qb_set_ub			= array();
-
 
158
 
152
	/**
159
	/**
153
	 * QB aliased tables list
160
	 * QB aliased tables list
154
	 *
161
	 *
155
	 * @var	array
162
	 * @var	array
156
	 */
163
	 */
Zeile 1393... Zeile 1400...
1393
		{
1400
		{
1394
			$orderby = $this->qb_orderby;
1401
			$orderby = $this->qb_orderby;
1395
			$this->qb_orderby = NULL;
1402
			$this->qb_orderby = NULL;
1396
		}
1403
		}
Zeile 1397... Zeile 1404...
1397
 
1404
 
1398
		$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby))
1405
		$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby))
1399
			? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
1406
			? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
Zeile 1400... Zeile 1407...
1400
			: $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
1407
			: $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
1401
 
1408
 
Zeile 1544... Zeile 1551...
1544
			$key = array($key => $value);
1551
			$key = array($key => $value);
1545
		}
1552
		}
Zeile 1546... Zeile 1553...
1546
 
1553
 
Zeile 1547... Zeile 1554...
1547
		is_bool($escape) OR $escape = $this->_protect_identifiers;
1554
		is_bool($escape) OR $escape = $this->_protect_identifiers;
1548
 
1555
 
Zeile 1549... Zeile 1556...
1549
		$keys = array_keys($this->_object_to_array(current($key)));
1556
		$keys = array_keys($this->_object_to_array(reset($key)));
1550
		sort($keys);
1557
		sort($keys);
1551
 
1558
 
Zeile 1884... Zeile 1891...
1884
			return ($this->db_debug) ? $this->display_error('db_must_use_index') : FALSE;
1891
			return ($this->db_debug) ? $this->display_error('db_must_use_index') : FALSE;
1885
		}
1892
		}
Zeile 1886... Zeile 1893...
1886
 
1893
 
1887
		if ($set === NULL)
1894
		if ($set === NULL)
1888
		{
1895
		{
1889
			if (empty($this->qb_set))
1896
			if (empty($this->qb_set_ub))
1890
			{
1897
			{
1891
				return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
1898
				return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
1892
			}
1899
			}
1893
		}
1900
		}
Zeile 1911... Zeile 1918...
1911
			$table = $this->qb_from[0];
1918
			$table = $this->qb_from[0];
1912
		}
1919
		}
Zeile 1913... Zeile 1920...
1913
 
1920
 
1914
		// Batch this baby
1921
		// Batch this baby
1915
		$affected_rows = 0;
1922
		$affected_rows = 0;
1916
		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size)
1923
		for ($i = 0, $total = count($this->qb_set_ub); $i < $total; $i += $batch_size)
1917
		{
1924
		{
1918
			if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $index)))
1925
			if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set_ub, $i, $batch_size), $index)))
1919
			{
1926
			{
1920
				$affected_rows += $this->affected_rows();
1927
				$affected_rows += $this->affected_rows();
Zeile 1921... Zeile 1928...
1921
			}
1928
			}
Zeile 1939... Zeile 1946...
1939
	 * @param	string	$index	WHERE key
1946
	 * @param	string	$index	WHERE key
1940
	 * @return	string
1947
	 * @return	string
1941
	 */
1948
	 */
1942
	protected function _update_batch($table, $values, $index)
1949
	protected function _update_batch($table, $values, $index)
1943
	{
1950
	{
1944
		$index_escaped = $this->protect_identifiers($index);
-
 
1945
 
-
 
1946
		$ids = array();
1951
		$ids = array();
1947
		foreach ($values as $key => $val)
1952
		foreach ($values as $key => $val)
1948
		{
1953
		{
1949
			$ids[] = $val[$index];
1954
			$ids[] = $val[$index]['value'];
Zeile 1950... Zeile 1955...
1950
 
1955
 
1951
			foreach (array_keys($val) as $field)
1956
			foreach (array_keys($val) as $field)
1952
			{
1957
			{
1953
				if ($field !== $index)
1958
				if ($field !== $index)
1954
				{
1959
				{
1955
					$final[$field][] = 'WHEN '.$index_escaped.' = '.$val[$index].' THEN '.$val[$field];
1960
					$final[$val[$field]['field']][] = 'WHEN '.$val[$index]['field'].' = '.$val[$index]['value'].' THEN '.$val[$field]['value'];
1956
				}
1961
				}
1957
			}
1962
			}
Zeile 1958... Zeile 1963...
1958
		}
1963
		}
Zeile 1963... Zeile 1968...
1963
			$cases .= $k." = CASE \n"
1968
			$cases .= $k." = CASE \n"
1964
				.implode("\n", $v)."\n"
1969
				.implode("\n", $v)."\n"
1965
				.'ELSE '.$k.' END, ';
1970
				.'ELSE '.$k.' END, ';
1966
		}
1971
		}
Zeile 1967... Zeile 1972...
1967
 
1972
 
Zeile 1968... Zeile 1973...
1968
		$this->where($index_escaped.' IN('.implode(',', $ids).')', NULL, FALSE);
1973
		$this->where($val[$index]['field'].' IN('.implode(',', $ids).')', NULL, FALSE);
1969
 
1974
 
Zeile 1970... Zeile 1975...
1970
		return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
1975
		return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
Zeile 2000... Zeile 2005...
2000
				if ($k2 === $index)
2005
				if ($k2 === $index)
2001
				{
2006
				{
2002
					$index_set = TRUE;
2007
					$index_set = TRUE;
2003
				}
2008
				}
Zeile -... Zeile 2009...
-
 
2009
 
-
 
2010
				$clean[$k2] = array(
2004
 
2011
					'field'  => $this->protect_identifiers($k2, FALSE, $escape),
-
 
2012
					'value'  => ($escape === FALSE ? $v2 : $this->escape($v2))
2005
				$clean[$this->protect_identifiers($k2, FALSE, $escape)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
2013
				);
Zeile 2006... Zeile 2014...
2006
			}
2014
			}
2007
 
2015
 
2008
			if ($index_set === FALSE)
2016
			if ($index_set === FALSE)
2009
			{
2017
			{
Zeile 2010... Zeile 2018...
2010
				return $this->display_error('db_batch_missing_index');
2018
				return $this->display_error('db_batch_missing_index');
2011
			}
2019
			}
Zeile 2012... Zeile 2020...
2012
 
2020
 
2013
			$this->qb_set[] = $clean;
2021
			$this->qb_set_ub[] = $clean;
Zeile 2775... Zeile 2783...
2775
	 */
2783
	 */
2776
	protected function _reset_write()
2784
	protected function _reset_write()
2777
	{
2785
	{
2778
		$this->_reset_run(array(
2786
		$this->_reset_run(array(
2779
			'qb_set'	=> array(),
2787
			'qb_set'	=> array(),
-
 
2788
			'qb_set_ub'	=> array(),
2780
			'qb_from'	=> array(),
2789
			'qb_from'	=> array(),
2781
			'qb_join'	=> array(),
2790
			'qb_join'	=> array(),
2782
			'qb_where'	=> array(),
2791
			'qb_where'	=> array(),
2783
			'qb_orderby'	=> array(),
2792
			'qb_orderby'	=> array(),
2784
			'qb_keys'	=> array(),
2793
			'qb_keys'	=> array(),