mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 23:32:54 +09:00
Updated DB classes for supporting prepared statements - SQL string can now be returned with '?' instead of argument values.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8458 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
313bfca8e8
commit
b6a1088995
14 changed files with 107 additions and 52 deletions
|
|
@ -14,8 +14,14 @@
|
|||
|
||||
class XmlQueryParser extends XmlParser {
|
||||
var $dbParser;
|
||||
var $db_type;
|
||||
|
||||
function XmlQueryParser($db_type = NULL){
|
||||
$this->db_type = $db_type;
|
||||
}
|
||||
|
||||
function parse($query_id, $xml_file, $cache_file) {
|
||||
|
||||
// Read xml file
|
||||
$xml_obj = $this->getXmlFileContent($xml_file);
|
||||
|
||||
|
|
@ -29,15 +35,17 @@
|
|||
}
|
||||
|
||||
// singleton
|
||||
/* function &getDBParser(){
|
||||
function &getDBParser(){
|
||||
static $dbParser;
|
||||
if(!$dbParser){
|
||||
//$oDB = &DB::getInstance();
|
||||
//$dbParser = $oDB->getParser();
|
||||
return new DBParser('"');
|
||||
if(isset($this->db_type))
|
||||
$oDB = &DB::getInstance($this->db_type);
|
||||
else
|
||||
$oDB = &DB::getInstance();
|
||||
$dbParser = $oDB->getParser();
|
||||
}
|
||||
return $dbParser;
|
||||
}*/
|
||||
}
|
||||
|
||||
function getXmlFileContent($xml_file){
|
||||
$buff = FileHandler::readFile($xml_file);
|
||||
|
|
@ -46,11 +54,5 @@
|
|||
unset($buff);
|
||||
return $xml_obj;
|
||||
}
|
||||
|
||||
function &getDBParser(){
|
||||
if(!$this->dbParser)
|
||||
$this->dbParser = new DBParser('"');
|
||||
return $this->dbParser;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -119,9 +119,10 @@ class QueryParser {
|
|||
foreach($arguments as $argument){
|
||||
if(isset($argument) && $argument->getArgumentName()){
|
||||
$prebuff .= $argument->toString();
|
||||
$prebuff .= sprintf("$%s_argument->escapeValue('%s');\n"
|
||||
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
||||
, $argument->getArgumentName()
|
||||
, $this->column_type[$this->getQueryId()][$argument->getColumnName()] );
|
||||
$prebuff .= sprintf('$query->addArgument($%s_argument);', $argument->getArgumentName());
|
||||
}
|
||||
}
|
||||
$prebuff .= "\n";
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
$this->value = $default_value;
|
||||
}
|
||||
|
||||
function escapeValue($column_type){
|
||||
function setColumnType($column_type){
|
||||
if(!isset($this->value)) return;
|
||||
if($column_type === '') return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue