Subversion-Projekte lars-tiefland.ci

Revision

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

Revision 68 Revision 1257
Zeile 677... Zeile 677...
677
			elseif ( ! $this->_has_operator($k))
677
			elseif ( ! $this->_has_operator($k))
678
			{
678
			{
679
				// value appears not to have been set, assign the test to IS NULL
679
				// value appears not to have been set, assign the test to IS NULL
680
				$k .= ' IS NULL';
680
				$k .= ' IS NULL';
681
			}
681
			}
682
			elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
682
			elseif (preg_match('/\s*(!?=|<>|\sIS(?:\s+NOT)?\s)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
683
			{
683
			{
684
				$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
684
				$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
685
			}
685
			}
Zeile 686... Zeile 686...
686
 
686
 
Zeile 1269... Zeile 1269...
1269
	 * @param	string	$sql	SQL Query
1269
	 * @param	string	$sql	SQL Query
1270
	 * @return	string
1270
	 * @return	string
1271
	 */
1271
	 */
1272
	protected function _limit($sql)
1272
	protected function _limit($sql)
1273
	{
1273
	{
1274
		return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').$this->qb_limit;
1274
		return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').(int) $this->qb_limit;
1275
	}
1275
	}
Zeile 1276... Zeile 1276...
1276
 
1276
 
Zeile 1277... Zeile 1277...
1277
	// --------------------------------------------------------------------
1277
	// --------------------------------------------------------------------
Zeile 1913... Zeile 1913...
1913
 
1913
 
1914
		// Batch this baby
1914
		// Batch this baby
1915
		$affected_rows = 0;
1915
		$affected_rows = 0;
1916
		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size)
1916
		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size)
1917
		{
1917
		{
1918
			if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $this->protect_identifiers($index))))
1918
			if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $index)))
1919
			{
1919
			{
1920
				$affected_rows += $this->affected_rows();
1920
				$affected_rows += $this->affected_rows();
Zeile 1921... Zeile 1921...
1921
			}
1921
			}
Zeile 1939... Zeile 1939...
1939
	 * @param	string	$index	WHERE key
1939
	 * @param	string	$index	WHERE key
1940
	 * @return	string
1940
	 * @return	string
1941
	 */
1941
	 */
1942
	protected function _update_batch($table, $values, $index)
1942
	protected function _update_batch($table, $values, $index)
1943
	{
1943
	{
-
 
1944
		$index_escaped = $this->protect_identifiers($index);
-
 
1945
 
1944
		$ids = array();
1946
		$ids = array();
1945
		foreach ($values as $key => $val)
1947
		foreach ($values as $key => $val)
1946
		{
1948
		{
1947
			$ids[] = $val[$index];
1949
			$ids[] = $val[$index];
Zeile 1948... Zeile 1950...
1948
 
1950
 
1949
			foreach (array_keys($val) as $field)
1951
			foreach (array_keys($val) as $field)
1950
			{
1952
			{
1951
				if ($field !== $index)
1953
				if ($field !== $index)
1952
				{
1954
				{
1953
					$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
1955
					$final[$field][] = 'WHEN '.$index_escaped.' = '.$val[$index].' THEN '.$val[$field];
1954
				}
1956
				}
1955
			}
1957
			}
Zeile 1956... Zeile 1958...
1956
		}
1958
		}
Zeile 1961... Zeile 1963...
1961
			$cases .= $k." = CASE \n"
1963
			$cases .= $k." = CASE \n"
1962
				.implode("\n", $v)."\n"
1964
				.implode("\n", $v)."\n"
1963
				.'ELSE '.$k.' END, ';
1965
				.'ELSE '.$k.' END, ';
1964
		}
1966
		}
Zeile 1965... Zeile 1967...
1965
 
1967
 
Zeile 1966... Zeile 1968...
1966
		$this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);
1968
		$this->where($index_escaped.' IN('.implode(',', $ids).')', NULL, FALSE);
1967
 
1969
 
Zeile 1968... Zeile 1970...
1968
		return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
1970
		return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
Zeile 2338... Zeile 2340...
2338
			.$this->_compile_group_by()
2340
			.$this->_compile_group_by()
2339
			.$this->_compile_wh('qb_having')
2341
			.$this->_compile_wh('qb_having')
2340
			.$this->_compile_order_by(); // ORDER BY
2342
			.$this->_compile_order_by(); // ORDER BY
Zeile 2341... Zeile 2343...
2341
 
2343
 
2342
		// LIMIT
2344
		// LIMIT
2343
		if ($this->qb_limit)
2345
		if ($this->qb_limit OR $this->qb_offset)
2344
		{
2346
		{
2345
			return $this->_limit($sql."\n");
2347
			return $this->_limit($sql."\n");
Zeile 2346... Zeile 2348...
2346
		}
2348
		}