本文整理匯總了PHP中SqlParser::takeOffComments方法的典型用法代碼示例。如果您正苦於以下問題:PHP SqlParser::takeOffComments方法的具體用法?PHP SqlParser::takeOffComments怎麽用?PHP SqlParser::takeOffComments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SqlParser
的用法示例。
在下文中一共展示了SqlParser::takeOffComments方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parse
/**
* @purpose : Parses SQL file
* @params string $content Text containing sql instructions
* @return array List of sql parsed from $content
*/
public static function parse($content)
{
$sqlList = array();
// Processing the SQL file content
$lines = explode("\n", $content);
$query = "";
// Parsing the SQL file content
foreach ($lines as $sql_line) {
$sql_line = trim($sql_line);
if ($sql_line === "") {
continue;
} else {
if (strpos($sql_line, "--") === 0) {
continue;
} else {
if (strpos($sql_line, "#") === 0) {
continue;
}
}
}
$query .= $sql_line;
// Checking whether the line is a valid statement
if (preg_match("/(.*);/", $sql_line)) {
$query = trim($query);
$query = substr($query, 0, strlen($query) - 1);
$query = SqlParser::takeOffComments($query);
//store this query
$sqlList[] = $query;
//reset the variable
$query = "";
}
}
return $sqlList;
}