english/libraries/joomla/database/database.php
/**
	 * Splits a string of multiple queries into an array of individual queries.
	 *
	 * @param   string  Input SQL string with which to split into individual queries.
	 *
	 * @return  array   The queries from the input string separated into an array.
	 *
	 * @since   11.1
	 */
Splits a string of multiple queries into an array of individual queries.
@param   string  Input SQL string with which to split into individual queries.

@return  array   The queries from the input string separated into an array.


Splits a string of multiple queries into an array of individual queries . @param string Input SQL string with which to split into individual queries . @return array The queries from the input string separated into an array .
public static function splitSql($sql)
	{
		$start = 0;
		$open = false;
		$char = '';
		$end = strlen($sql);
		$queries = array();
		for ($i = 0; $i < $end; $i++)
		{
			$current = substr($sql,$i,1);
			if (($current == '"' || $current == '\'')) {
				$n = 2;
				while (substr($sql,$i - $n + 1, 1) == '\\' && $n < $i)
				{
					$n ++;
				}
				if ($n%2==0) {
					if ($open) {
						if ($current == $char) {
							$open = false;
							$char = '';
						}
					} else {
						$open = true;
						$char = $current;
					}
				}
			}
			if (($current == ';' && !$open)|| $i == $end - 1) {
				$queries[] = substr($sql, $start, ($i - $start + 1));
				$start = $i + 1;
			}
		}
		return $queries;
	}
public static function splitSql ( $ sql ) { $ start = 0 ; $ open = false ; $ char = '' ; $ end = strlen ( $ sql ) ; $ queries = array ( ) ; for ( $ i = 0 ; $ i < $ end ; $ i ++ ) { $ current = substr ( $ sql , $ i , 1 ) ; if ( ( $ current == '"' || $ current == '\'' ) ) { $ n = 2 ; while ( substr ( $ sql , $ i - $ n + 1 , 1 ) == '\\' && $ n < $ i ) { $ n ++ ; } if ( $ n % 2 == 0 ) { if ( $ open ) { if ( $ current == $ char ) { $ open = false ; $ char = '' ; } } else { $ open = true ; $ char = $ current ; } } } if ( ( $ current == ';' && ! $ open ) || $ i == $ end - 1 ) { $ queries [ ] = substr ( $ sql , $ start , ( $ i - $ start + 1 ) ) ; $ start = $ i + 1 ; } } return $ queries ; }
Splits a string of multiple queries into an array of individual queries.
Splits a string of multiple queries into an array of individual queries .