/** * Read a multiline sql command from a file. * * Supports the formatting created by mysqldump, but won't handle multiline comments. * @param \BackupMigrate\Core\File\BackupFileReadableInterface $file * @return string */ protected function _readSQLCommand(BackupFileReadableInterface $file) { $out = ''; while ($line = $file->readLine()) { $first2 = substr($line, 0, 2); $first3 = substr($line, 0, 2); // Ignore single line comments. This function doesn't support multiline comments or inline comments. if ($first2 != '--' && ($first2 != '/*' || $first3 == '/*!')) { $out .= ' ' . trim($line); // If a line ends in ; or */ it is a sql command. if (substr($out, strlen($out) - 1, 1) == ';') { return trim($out); } } } return trim($out); }