本文整理匯總了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;
}