vovanium
Новичок
В продолжение темы, парсер SQL-дампа в mysqldumper, вроде ж более менее серьёзная софтина. Но вот как там ищется название таблицы в запросах из дампа.
Особенно конечно убивает посимвольный поиск
И вроде ж автор знает и даже использовал функцию strpos (не говоря о регулярках). Ну и конечно удаление кавычек разделителей "`", вместо того чтобы сразу вырезать нужное 
PHP:
$t=substr($t,0,150);
$t=str_ireplace('DROP TABLE','',$t);
$t=str_ireplace('DROP VIEW','',$t);
$t=str_ireplace('CREATE TABLE','',$t);
$t=str_ireplace('INSERT INTO','',$t);
$t=str_ireplace('REPLACE INTO','',$t);
$t=str_ireplace('IF NOT EXISTS','',$t);
$t=str_ireplace('IF EXISTS','',$t);
if (substr(strtoupper($t),0,16) == 'CREATE ALGORITHM')
{
$pos=strpos($sql,'DEFINER VIEW ');
$t=substr($t,$pos,strlen($t) - $pos);
}
$t=str_ireplace(';',' ;',$t); // tricky -> insert space as delimiter
$t=trim($t);
$delimiter=substr($t,0,1);
if ($delimiter != '`') $delimiter=' ';
$found=false;
$position=1;
WHILE (!$found)
{
if (substr($t,$position,1) == $delimiter) $found=true;
if ($position >= strlen($t)) $found=true;
$position++;
}
$t=substr($t,0,$position);
$t=trim(str_replace('`','',$t));

