/** * 加载sql文件为分号分割的数组 * 支持存储过程和函数提取,自动过滤注释 * @param string $path 文件路径 * @return boolean|array * @since 1.0 <2015-5-27> SoChishun Added. */ function load_sql_file($path, $fn_splitor = ';;') { if (!file_exists($path)) { return false; } $lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $arr = false; $str = ''; $skip = false; $fn = false; foreach ($lines as $line) { $line = trim($line); // 过滤注释 if (!$line || 0 === strpos($line, '--') || 0 === strpos('*') || 0 === strpos($line, '/*') || (false !== strpos($line, '*/') && strlen($line) == (strpos($line, '*/') + 2))) { if (!$skip && 0 === strpos($line, '/*')) { $skip = true; } if ($skip && false !== strpos($line, '*/') && strlen($line) == (strpos($line, '*/') + 2)) { $skip = false; } continue; } if ($skip) { continue; } // 提取存储过程和函数 if (0 === strpos($line, 'DELIMITER ' . $fn_splitor)) { $fn = true; continue; } if (0 === strpos($line, 'DELIMITER ;')) { $fn = false; $arr[] = $str; $str = ''; continue; } if ($fn) { $str.=$line . ' '; continue; } // 提取普通语句 $str.=$line; if (false !== strpos($line, ';') && strlen($line) == (strpos($line, ';') + 1)) { $arr[] = $str; $str = ''; } } return $arr; }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool