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

@ -566,12 +566,7 @@
}
function getInsertSql($query){
$tableName = $query->getFirstTableName();
$values = $query->getInsertString();
return "INSERT INTO $tableName \n $values";
}
/**
* @brief handles insertAct
@ -589,19 +584,6 @@
return $result;
}
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;
}
/**
* @brief handles updateAct
@ -616,18 +598,6 @@
return $result;
}
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;
}
/**
* @brief handles deleteAct
@ -641,31 +611,6 @@
return $result;
}
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;
}
/**
* @brief Handle selectAct
@ -677,7 +622,7 @@
function _executeSelectAct($queryObject){
$query = $this->getSelectSql($queryObject);
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$result = $this->_query ($query);
if ($this->isError ()) {
@ -712,8 +657,7 @@
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
$data = $this->_fetch($result);
//$data = $this->_fetch($result, $virtual_no);
$data = $this->_fetch($result, $virtual_no);
$buff = new Object ();
$buff->total_count = $total_count;
@ -729,6 +673,10 @@
return $buff;
}
function getParser(){
return new DBParser('"');
}
}
return new DBCubrid;