mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-22 04:39:55 +09:00
Updated query classes in order to support prepared statements - added support for parameter binding. Added unit tests for mssql select using new prepared statement syntax.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8511 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
32fe8750e9
commit
6f17aa5759
11 changed files with 93 additions and 16 deletions
|
|
@ -11,12 +11,8 @@
|
|||
var $orderby;
|
||||
var $limit;
|
||||
|
||||
var $arguments = array();
|
||||
|
||||
function addArgument($argument){
|
||||
$this->arguments[] = $argument;
|
||||
}
|
||||
|
||||
var $arguments = null;
|
||||
|
||||
function setQueryId($queryID){
|
||||
$this->queryID = $queryID;
|
||||
}
|
||||
|
|
@ -202,6 +198,35 @@
|
|||
function getFirstTableName(){
|
||||
return $this->tables[0]->getName();
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
if(!isset($this->arguments)){
|
||||
$this->arguments = array();
|
||||
|
||||
// Column arguments
|
||||
foreach($this->columns as $column){
|
||||
if($column->show()){
|
||||
$arg = $column->getArgument();
|
||||
if($arg) $this->arguments[] = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
// Condition arguments
|
||||
if(count($this->conditions) > 0)
|
||||
foreach($this->conditions as $conditionGroup){
|
||||
$args = $conditionGroup->getArguments();
|
||||
if(count($args) > 0) $this->arguments = array_merge($this->arguments, $args);
|
||||
}
|
||||
|
||||
// Navigation arguments
|
||||
if(count($this->orderby) > 0)
|
||||
foreach($this->orderby as $order){
|
||||
$args = $order->getArguments();
|
||||
if(count($args) > 0) $this->arguments = array_merge($this->arguments, $args);
|
||||
}
|
||||
}
|
||||
return $this->arguments;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@
|
|||
return is_a($this->argument, 'Argument');
|
||||
}
|
||||
|
||||
function getArgument(){
|
||||
if($this->hasArgument()) return $this->argument;
|
||||
return null;
|
||||
}
|
||||
|
||||
function toString($withValue = true){
|
||||
if($withValue)
|
||||
return $this->toStringWithValue();
|
||||
|
|
|
|||
|
|
@ -31,5 +31,16 @@
|
|||
|
||||
return $group;
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
$args = array();
|
||||
foreach($this->conditions as $condition){
|
||||
if($condition->show()){
|
||||
$arg = $condition->getArgument();
|
||||
if($arg) $args[] = $arg;
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -26,6 +26,10 @@
|
|||
if(!isset($value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getArgument(){
|
||||
return $this->argument;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -28,5 +28,9 @@
|
|||
function show() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getArgument(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -12,5 +12,9 @@
|
|||
function StarExpression(){
|
||||
parent::SelectExpression("*");
|
||||
}
|
||||
|
||||
function getArgument(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -40,6 +40,10 @@
|
|||
if(!$this->argument->getValue()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getArgument(){
|
||||
return $this->argument;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@
|
|||
$result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
$args = array();
|
||||
if(is_a($this->column_name, 'Argument'))
|
||||
$args[]= $this->column_name;
|
||||
if(is_a($this->sort_order, 'Argument'))
|
||||
$args[] = $this->sort_order;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -109,6 +109,7 @@ class QueryParser {
|
|||
|
||||
$this->setTableColumnTypes($tables);
|
||||
|
||||
// TODO Check if this work with arguments in join clause
|
||||
$arguments = array();
|
||||
if($columns)
|
||||
$arguments = array_merge($arguments, $columns->getArguments());
|
||||
|
|
@ -122,7 +123,6 @@ class QueryParser {
|
|||
$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";
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@
|
|||
$this->isValid = true;
|
||||
}
|
||||
|
||||
function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function getValue(){
|
||||
if(is_array($this->value)) return implode(',', $this->value);
|
||||
return $this->value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue