/**
* Split the SQL dump code and return as queries array.
* @param string $raw SQL code to parse
* @return array List of queries
*/
function splitSqlText ( $raw ) {
// the regex needs a trailing semicolon
$raw = trim ( (string) $raw );
if ( substr ( $raw, -1 ) !== ";") {
$raw .= ";";
}
// i spent 3 days figuring out this line
preg_match_all( "/(?>[^;']|(''|(?>'([^']|\\')*[^\\\]')".
"))+;/ixU", $raw, $matches, PREG_SET_ORDER );
$querySplit = [];
foreach ( $matches as $match ) {
// get rid of the trailing semicolon
$querySplit[] = substr( $match[0], 0, -1 );
}
return $querySplit;
}
Чтобы увидеть комментарии, нужно быть участником сообщества
Регистрация