本文整理汇总了PHP中SqlParser::parseSqlQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlParser::parseSqlQuery方法的具体用法?PHP SqlParser::parseSqlQuery怎么用?PHP SqlParser::parseSqlQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlParser
的用法示例。
在下文中一共展示了SqlParser::parseSqlQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeQuery
function executeQuery($sql_query_str)
{
set_error_handler("txtdbapi_error_handler");
txtdbapi_clear_errors();
debug_printb("[executeQuery] Query: {$sql_query_str}<br>");
// Parse Query
$start = getmicrotime();
$sqlParser = new SqlParser($sql_query_str);
$sqlQuery = $sqlParser->parseSqlQuery();
debug_print("parseSqlQuery: " . (getmicrotime() - $start) . " seconds elapsed<br>");
// free $sqlParser
unset($sqlParser);
$sqlParser = "";
// Test Query
if (!$sqlQuery || !$sqlQuery->test()) {
restore_error_handler();
return false;
}
$start = getmicrotime();
debug_printb("[executeQuery] Parsed Query:<br>");
if (TXTDBAPI_DEBUG) {
$sqlQuery->dump();
}
// Dispatch
switch ($sqlQuery->type) {
case "SELECT":
$rc = $this->executeSelectQuery($sqlQuery);
break;
case "INSERT":
$rc = $this->executeInsertQuery($sqlQuery);
break;
case "DELETE":
$rc = $this->executeDeleteQuery($sqlQuery);
break;
case "UPDATE":
$rc = $this->executeUpdateQuery($sqlQuery);
break;
case "CREATE TABLE":
$rc = $this->executeCreateTableQuery($sqlQuery);
break;
case "DROP TABLE":
$rc = $this->executeDropTableQuery($sqlQuery);
break;
case "CREATE DATABASE":
$rc = $this->executeCreateDatabaseQuery($sqlQuery);
break;
case "DROP DATABASE":
$rc = $this->executeDropDatabaseQuery($sqlQuery);
break;
case "LIST TABLES":
$rc = $this->executeListTablesQuery($sqlQuery);
break;
default:
print_error_msg("Invalid or unsupported Query Type: " . $sqlQuery->type);
restore_error_handler();
return false;
}
if (is_false($rc)) {
print_error_msg("Query '" . $sql_query_str . "' failed");
}
debug_printb("[executeQuery] Query execution done: " . (getmicrotime() - $start) . " seconds elapsed<br>");
restore_error_handler();
return $rc;
}