src/DatabaseHelper.php
public static function splitSql($sql)
  {
    $start = 0;
    $open = false;
    $char = '';
    $end = strlen($sql);
    $queries = [];

    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 = [];

    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 = [ ] ; 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.

@param   string  $sql  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 .