SqlParser\Utils\BufferedQuery::setDelimiter PHP Method

setDelimiter() public method

Used to update the length of it too.
public setDelimiter ( string $delimiter )
$delimiter string
    public function setDelimiter($delimiter)
    {
        $this->delimiter = $delimiter;
        $this->delimiterLen = strlen($delimiter);
    }

Usage Example

 /**
  * Handles the whole import logic
  *
  * @param array &$sql_data 2-element array with sql data
  *
  * @return void
  */
 public function doImport(&$sql_data = array())
 {
     global $error, $timeout_passed;
     // Handle compatibility options.
     $this->_setSQLMode($GLOBALS['dbi'], $_REQUEST);
     $bq = new SqlParser\Utils\BufferedQuery();
     if (isset($_POST['sql_delimiter'])) {
         $bq->setDelimiter($_POST['sql_delimiter']);
     }
     /**
      * Will be set in PMA_importGetNextChunk().
      *
      * @global bool $GLOBALS ['finished']
      */
     $GLOBALS['finished'] = false;
     while (!$error && !$timeout_passed) {
         // Getting the first statement, the remaining data and the last
         // delimiter.
         $statement = $bq->extract();
         // If there is no full statement, we are looking for more data.
         if (empty($statement)) {
             // Importing new data.
             $newData = PMA_importGetNextChunk();
             // Subtract data we didn't handle yet and stop processing.
             if ($newData === false) {
                 $GLOBALS['offset'] -= mb_strlen($bq->query);
                 break;
             }
             // Checking if the input buffer has finished.
             if ($newData === true) {
                 $GLOBALS['finished'] = true;
                 break;
             }
             // Convert CR (but not CRLF) to LF otherwise all queries may
             // not get executed on some platforms.
             $bq->query .= preg_replace("/\r(\$|[^\n])/", "\n\$1", $newData);
             continue;
         }
         // Executing the query.
         PMA_importRunQuery($statement, $statement, false, $sql_data);
     }
     // Extracting remaining statements.
     while (!$error && !$timeout_passed && !empty($bq->query)) {
         $statement = $bq->extract(true);
         if (!empty($statement)) {
             PMA_importRunQuery($statement, $statement, false, $sql_data);
         }
     }
     // Finishing.
     PMA_importRunQuery('', '', false, $sql_data);
 }