mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8556 201d5d3c-b55e-5fd7-737f-ddc643e51545
70 lines
2 KiB
PHP
70 lines
2 KiB
PHP
<?php
|
|
/**
|
|
* @class NewXmlQueryParser
|
|
* @author NHN (developers@xpressengine.com)
|
|
* @brief case to parse XE xml query
|
|
* @version 0.1
|
|
*
|
|
* @todo need to support extend query such as subquery, union
|
|
* @todo include info about column types for parsing user input
|
|
**/
|
|
|
|
require_once(_XE_PATH_.'classes/xml/xmlquery/DBParser.class.php');
|
|
require_once(_XE_PATH_.'classes/xml/xmlquery/QueryParser.class.php');
|
|
|
|
class XmlQueryParser extends XmlParser {
|
|
static $dbParser = null;
|
|
var $db_type;
|
|
|
|
function XmlQueryParser($db_type = NULL){
|
|
$this->db_type = $db_type;
|
|
}
|
|
|
|
function &getInstance($db_type = NULL){
|
|
static $theInstance = null;
|
|
if(!isset($theInstance)){
|
|
$theInstance = new XmlQueryParser($db_type);
|
|
}
|
|
return $theInstance;
|
|
}
|
|
|
|
function parse($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;
|
|
|
|
$parser = new QueryParser($xml_obj->query);
|
|
|
|
FileHandler::writeFile($cache_file, $parser->toString());
|
|
}
|
|
|
|
// singleton
|
|
function &getDBParser(){
|
|
if(!$self->dbParser){
|
|
is_a($this,'XmlQueryParser')?$self=&$this:$self=&XmlQueryParser::getInstance();
|
|
if(isset($self->db_type))
|
|
$oDB = &DB::getInstance($self->db_type);
|
|
else
|
|
$oDB = &DB::getInstance();
|
|
$self->dbParser = $oDB->getParser();
|
|
}
|
|
return $self->dbParser;
|
|
}
|
|
|
|
function setDBParser($value){
|
|
$self->dbParser = $value;
|
|
}
|
|
|
|
function getXmlFileContent($xml_file){
|
|
$buff = FileHandler::readFile($xml_file);
|
|
$xml_obj = parent::parse($buff);
|
|
if(!$xml_obj) return;
|
|
unset($buff);
|
|
return $xml_obj;
|
|
}
|
|
}
|
|
?>
|