Started work on MySql class.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8443 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-06-02 18:33:50 +00:00
parent 2e122219f1
commit 9ef9069ba2
3 changed files with 90 additions and 420 deletions

View file

@ -456,6 +456,63 @@
$query = sprintf("drop table %s%s", $this->prefix, $table_name);
$this->_query($query);
}
function getSelectSql($query){
$select = $query->getSelectString();
if($select == '') return new Object(-1, "Invalid query");
$select = 'SELECT ' .$select;
$from = $query->getFromString();
if($from == '') return new Object(-1, "Invalid query");
$from = ' FROM '.$from;
$where = $query->getWhereString();
if($where != '') $where = ' WHERE ' . $where;
$groupBy = $query->getGroupByString();
if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
$orderBy = $query->getOrderByString();
if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
$limit = $query->getLimitString();
if($limit != '') $limit = ' LIMIT ' . $limit;
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
}
function getDeleteSql($query){
$sql = 'DELETE ';
$from = $query->getFromString();
if($from == '') return new Object(-1, "Invalid query");
$sql .= ' FROM '.$from;
$where = $query->getWhereString();
if($where != '') $sql .= ' WHERE ' . $where;
return $sql;
}
function getUpdateSql($query){
$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();
if($where != '') $where = ' WHERE ' . $where;
return "UPDATE $tableName SET $columnsList ".$where;
}
function getInsertSql($query){
$tableName = $query->getFirstTableName();
$values = $query->getInsertString();
return "INSERT INTO $tableName \n $values";
}
}
?>