<?php

namespace Core;

class Query
{
	/**
	 * Separate queries from SQL script
	 *
	 * @param string $script SQL script
	 */
	static function separate($script, $strip = false)
	{
		$expression = '(?:--.*$|[\w_]+|[\d\.]+|\'(?:\'\'|[^\'])*\'|\'(?:""|[^"])*"|\'(?:``|[^`])*`|\#(?:\#\#|[^\#])*\#|[+-/%\.]|[^;])*(?:;|$)\s*';
		preg_match_all('@' . $expression . '@m', $script, $array, PREG_PATTERN_ORDER);
		unset($array[0][count($array[0]) - 1]);
		return $array[0];
	}
}
