* 2. Check the action
* 3. Parsing and write a cache file
* @return QueryParser object
*/
function &parse_xml_query($query_id, $xml_file, $cache_file)
{
// Read xml file
$xml_obj = $this->getXmlFileContent($xml_file);
// insert, update, delete, select action
$action = strtolower($xml_obj->query->attrs->action);
if(!$action) return;
// Write query cache file
$parser = new QueryParser($xml_obj->query);
FileHandler::writeFile($cache_file, $parser->toString());
return $parser;
}
/**
* Query XML file parsing
* @return QueryParser object
*/
function parse($query_id = NULL, $xml_file = NULL, $cache_file = NULL)
{
$this->parse_xml_query($query_id, $xml_file, $cache_file);
}
/**
* Return XML file content
* @return array|NULL Returns a resultant data object or NULL in case of error
*/
function getXmlFileContent($xml_file){
$buff = FileHandler::readFile($xml_file);
$xml_obj = parent::parse($buff);
if(!$xml_obj) return;
unset($buff);
return $xml_obj;
}
}
?>