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:
ucorina 2011-06-07 19:01:58 +00:00
parent 313bfca8e8
commit b6a1088995
14 changed files with 107 additions and 52 deletions

View file

@ -457,16 +457,16 @@
$this->_query($query);
}
function getSelectSql($query){
$select = $query->getSelectString();
function getSelectSql($query, $with_values = true){
$select = $query->getSelectString($with_values);
if($select == '') return new Object(-1, "Invalid query");
$select = 'SELECT ' .$select;
$from = $query->getFromString();
$from = $query->getFromString($with_values);
if($from == '') return new Object(-1, "Invalid query");
$from = ' FROM '.$from;
$where = $query->getWhereString();
$where = $query->getWhereString($with_values);
if($where != '') $where = ' WHERE ' . $where;
$groupBy = $query->getGroupByString();
@ -481,7 +481,7 @@
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
}
function getDeleteSql($query){
function getDeleteSql($query, $with_values = true){
$sql = 'DELETE ';
// TODO Add support for deleting based on alias, for both simple FROM and multi table join FROM clause
@ -489,32 +489,32 @@
$sql .= $tables[0]->getAlias();
$from = $query->getFromString();
$from = $query->getFromString($with_values);
if($from == '') return new Object(-1, "Invalid query");
$sql .= ' FROM '.$from;
$where = $query->getWhereString();
$where = $query->getWhereString($with_values);
if($where != '') $sql .= ' WHERE ' . $where;
return $sql;
}
function getUpdateSql($query){
function getUpdateSql($query, $with_values = true){
$columnsList = $query->getSelectString();
if($columnsList == '') return new Object(-1, "Invalid query");
$tableName = $query->getFirstTableName();
if($tableName == '') return new Object(-1, "Invalid query");
$where = $query->getWhereString();
$where = $query->getWhereString($with_values);
if($where != '') $where = ' WHERE ' . $where;
return "UPDATE $tableName SET $columnsList ".$where;
}
function getInsertSql($query){
function getInsertSql($query, $with_values = true){
$tableName = $query->getFirstTableName();
$values = $query->getInsertString();
$values = $query->getInsertString($with_values);
return "INSERT INTO $tableName \n $values";
}