Updated the query parts that work with arguments (conditions, update and insert expressions) to work with QueryArgument objects instead of string values.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8457 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-06-07 17:18:32 +00:00
parent e41c45433e
commit 313bfca8e8
18 changed files with 120 additions and 169 deletions

View file

@ -6,6 +6,7 @@
*
*/
// TODO Fix this class
class DeleteExpression extends Expression {
var $value;

View file

@ -8,19 +8,20 @@
*/
class InsertExpression extends Expression {
var $value;
var $argument;
function InsertExpression($column_name, $value){
function InsertExpression($column_name, $argument){
parent::Expression($column_name);
$this->value = $value;
$this->argument = $argument;
}
function getValue(){
return $this->value;
return $this->argument->getValue();
}
function show(){
if(!isset($this->value)) return false;
$value = $this->argument->getValue();
if(!isset($value)) return false;
return true;
}
}

View file

@ -7,25 +7,35 @@
*/
class UpdateExpression extends Expression {
var $value;
var $argument;
function UpdateExpression($column_name, $value){
function UpdateExpression($column_name, $argument){
parent::Expression($column_name);
$this->value = $value;
$this->argument = $argument;
}
function getExpression(){
return "$this->column_name = $this->value";
return $this->getExpressionWithValue();
}
function getExpressionWithValue(){
$value = $this->argument->getValue();
return "$this->column_name = $value";
}
function getExpressionWithoutValue(){
return "$this->column_name = ?";
}
function getValue(){
// TODO Escape value according to column type instead of variable type
if(!is_numeric($this->value)) return "'".$this->value."'";
return $this->value;
$value = $this->argument->getValue();
if(!is_numeric($value)) return "'".$value."'";
return $value;
}
function show(){
if(!$this->value) return false;
if(!$this->argument->getValue()) return false;
return true;
}
}