mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 23:32:54 +09:00
Close Connection when there is no connection value.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@13161 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
034a5c0288
commit
f70ce644ce
1410 changed files with 7188 additions and 53541 deletions
|
|
@ -158,6 +158,12 @@ class DB
|
|||
*/
|
||||
var $use_prepared_statements;
|
||||
|
||||
/**
|
||||
* leve of transaction
|
||||
* @var unknown
|
||||
*/
|
||||
private $transationNestedLevel = 0;
|
||||
|
||||
/**
|
||||
* returns instance of certain db type
|
||||
* @param string $db_type type of db
|
||||
|
|
@ -1160,14 +1166,15 @@ class DB
|
|||
*/
|
||||
function begin()
|
||||
{
|
||||
if(!$this->isConnected() || $this->transaction_started)
|
||||
if(!$this->isConnected())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->_begin())
|
||||
if($this->_begin($this->transationNestedLevel))
|
||||
{
|
||||
$this->transaction_started = TRUE;
|
||||
$this->transationNestedLevel++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1191,9 +1198,14 @@ class DB
|
|||
{
|
||||
return;
|
||||
}
|
||||
if($this->_rollback())
|
||||
if($this->_rollback($this->transationNestedLevel))
|
||||
{
|
||||
$this->transaction_started = FALSE;
|
||||
$this->transationNestedLevel--;
|
||||
|
||||
if(!$this->transationNestedLevel)
|
||||
{
|
||||
$this->transaction_started = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1218,9 +1230,14 @@ class DB
|
|||
{
|
||||
return;
|
||||
}
|
||||
if($this->_commit())
|
||||
if($this->transationNestedLevel == 1 && $this->_commit())
|
||||
{
|
||||
$this->transaction_started = FALSE;
|
||||
$this->transationNestedLevel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->transationNestedLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,12 +157,20 @@ class DBCubrid extends DB
|
|||
* this method is private
|
||||
* @return boolean
|
||||
*/
|
||||
function _begin()
|
||||
function _begin($transactionLevel)
|
||||
{
|
||||
if(__CUBRID_VERSION__ >= '8.4.0')
|
||||
{
|
||||
$connection = $this->_getConnection('master');
|
||||
cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE);
|
||||
|
||||
if(!$transactionLevel)
|
||||
{
|
||||
cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_query("SAVEPOINT SP" . $transactionLevel, $connection);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -172,10 +180,21 @@ class DBCubrid extends DB
|
|||
* this method is private
|
||||
* @return boolean
|
||||
*/
|
||||
function _rollback()
|
||||
function _rollback($transactionLevel)
|
||||
{
|
||||
$connection = $this->_getConnection('master');
|
||||
@cubrid_rollback($connection);
|
||||
|
||||
$point = $transactionLevel - 1;
|
||||
|
||||
if($point)
|
||||
{
|
||||
$this->_query("ROLLBACK TO SP" . $point, $connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
@cubrid_rollback($connection);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -858,6 +877,7 @@ class DBCubrid extends DB
|
|||
$query = $this->getInsertSql($queryObject, $with_values);
|
||||
if(is_a($query, 'Object'))
|
||||
{
|
||||
unset($this->param);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -888,6 +908,7 @@ class DBCubrid extends DB
|
|||
$query = $this->getUpdateSql($queryObject, $with_values);
|
||||
if(is_a($query, 'Object'))
|
||||
{
|
||||
unset($this->param);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -919,6 +940,7 @@ class DBCubrid extends DB
|
|||
$query = $this->getDeleteSql($queryObject, $with_values);
|
||||
if(is_a($query, 'Object'))
|
||||
{
|
||||
unset($this->param);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -961,6 +983,7 @@ class DBCubrid extends DB
|
|||
$query = $this->getSelectSql($queryObject, $with_values);
|
||||
if(is_a($query, 'Object'))
|
||||
{
|
||||
unset($this->param);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -969,6 +992,7 @@ class DBCubrid extends DB
|
|||
|
||||
if($this->isError())
|
||||
{
|
||||
unset($this->param);
|
||||
return $this->queryError($queryObject);
|
||||
}
|
||||
|
||||
|
|
@ -1049,7 +1073,7 @@ class DBCubrid extends DB
|
|||
$page_count = 10;
|
||||
}
|
||||
$page = $limit->page->getValue();
|
||||
if(!$page)
|
||||
if(!$page || $page < 1)
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
|
@ -1075,6 +1099,7 @@ class DBCubrid extends DB
|
|||
$buff->page = $page;
|
||||
$buff->data = array();
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
|
||||
unset($this->param);
|
||||
return $buff;
|
||||
}
|
||||
$start_count = ($page - 1) * $list_count;
|
||||
|
|
@ -1084,6 +1109,7 @@ class DBCubrid extends DB
|
|||
$result = $this->_query($query, $connection);
|
||||
if($this->isError())
|
||||
{
|
||||
unset($this->param);
|
||||
return $this->queryError($queryObject);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,12 +126,20 @@ class DBMssql extends DB
|
|||
* this method is private
|
||||
* @return boolean
|
||||
*/
|
||||
function _begin()
|
||||
function _begin($transactionLevel)
|
||||
{
|
||||
$connection = $this->_getConnection('master');
|
||||
if(sqlsrv_begin_transaction($connection) === false)
|
||||
|
||||
if(!$transactionLevel)
|
||||
{
|
||||
return;
|
||||
if(sqlsrv_begin_transaction($connection) === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_query("SAVE TRANS SP" . $transactionLevel, $connection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -141,10 +149,20 @@ class DBMssql extends DB
|
|||
* this method is private
|
||||
* @return boolean
|
||||
*/
|
||||
function _rollback()
|
||||
function _rollback($transactionLevel)
|
||||
{
|
||||
$connection = $this->_getConnection('master');
|
||||
sqlsrv_rollback($connection);
|
||||
|
||||
$point = $transactionLevel - 1;
|
||||
|
||||
if($point)
|
||||
{
|
||||
$this->_query("ROLLBACK TRANS SP" . $point, $connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlsrv_rollback($connection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -725,7 +743,7 @@ class DBMssql extends DB
|
|||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getSelectSql($query, $with_values = TRUE)
|
||||
function getSelectSql($query, $with_values = TRUE, $connection=NULL)
|
||||
{
|
||||
$with_values = false;
|
||||
|
||||
|
|
@ -783,7 +801,49 @@ class DBMssql extends DB
|
|||
$orderBy = ' ORDER BY ' . $orderBy;
|
||||
}
|
||||
|
||||
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy;
|
||||
if($limitCount != '' && $query->limit->start > 0)
|
||||
{
|
||||
$order = $query->getOrder();
|
||||
$first_columns = array();
|
||||
foreach($order as $val)
|
||||
{
|
||||
$tmpColumnName = $val->getPureColumnName();
|
||||
$first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder()=='asc'?'max':'min', $tmpColumnName, $tmpColumnName);
|
||||
$first_sub_columns[] = $tmpColumnName;
|
||||
}
|
||||
|
||||
$first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',',$first_columns), $query->limit->start, implode(',',$first_sub_columns), $from, $where, $groupBy, $orderBy);
|
||||
$this->param = $query->getArguments();
|
||||
$result = $this->__query($first_query, $connection);
|
||||
$tmp = $this->_fetch($result);
|
||||
|
||||
$sub_cond = array();
|
||||
foreach($order as $k => $v)
|
||||
{
|
||||
//for example... use Document
|
||||
if(get_class($v->sort_order) == 'SortArgument')
|
||||
{
|
||||
$sort_order = $v->sort_order->value;
|
||||
}
|
||||
//for example... use comment, file
|
||||
else
|
||||
{
|
||||
$sort_order = $v->sort_order;
|
||||
}
|
||||
|
||||
$sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order=='asc'?'>':'<', $tmp->{$v->getPureColumnName()});
|
||||
}
|
||||
|
||||
if(!$where)
|
||||
{
|
||||
$sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sub_condition = ' and ( '.implode(' and ',$sub_cond).' )';
|
||||
}
|
||||
}
|
||||
return $select . ' ' . $from . ' ' . $where .$sub_condition. ' ' . $groupBy . ' ' . $orderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -796,7 +856,7 @@ class DBMssql extends DB
|
|||
*/
|
||||
function _executeSelectAct($queryObject, $connection = null)
|
||||
{
|
||||
$query = $this->getSelectSql($queryObject);
|
||||
$query = $this->getSelectSql($queryObject, true, $connection);
|
||||
|
||||
if(strpos($query, "substr"))
|
||||
{
|
||||
|
|
@ -903,7 +963,7 @@ class DBMssql extends DB
|
|||
$page_count = 10;
|
||||
}
|
||||
$page = $limit->page->getValue();
|
||||
if(!$page)
|
||||
if(!$page || $page < 1)
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ class DBMysql extends DB
|
|||
$page_count = 10;
|
||||
}
|
||||
$page = $limit->page->getValue();
|
||||
if(!$page)
|
||||
if(!$page || $page < 1)
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,10 +51,18 @@ class DBMysql_innodb extends DBMysql
|
|||
* this method is private
|
||||
* @return boolean
|
||||
*/
|
||||
function _begin()
|
||||
function _begin($transactionLevel)
|
||||
{
|
||||
$connection = $this->_getConnection('master');
|
||||
$this->_query("begin", $connection);
|
||||
|
||||
if(!$transactionLevel)
|
||||
{
|
||||
$this->_query("START TRANSACTION", $connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_query("SAVEPOINT SP" . $transactionLevel, $connection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -63,10 +71,20 @@ class DBMysql_innodb extends DBMysql
|
|||
* this method is private
|
||||
* @return boolean
|
||||
*/
|
||||
function _rollback()
|
||||
function _rollback($transactionLevel)
|
||||
{
|
||||
$connection = $this->_getConnection('master');
|
||||
$this->_query("rollback", $connection);
|
||||
|
||||
$point = $transactionLevel - 1;
|
||||
|
||||
if($point)
|
||||
{
|
||||
$this->_query("ROLLBACK TO SP" . $point, $connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_query("ROLLBACK", $connection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +109,11 @@ class DBMysql_innodb extends DBMysql
|
|||
*/
|
||||
function __query($query, $connection)
|
||||
{
|
||||
if(!$connection)
|
||||
{
|
||||
Context::close();
|
||||
exit();
|
||||
}
|
||||
// Run the query statement
|
||||
$result = @mysql_query($query, $connection);
|
||||
// Error Check
|
||||
|
|
|
|||
|
|
@ -245,6 +245,11 @@ class Query extends Object
|
|||
$this->orderby = $order;
|
||||
}
|
||||
|
||||
function getOrder()
|
||||
{
|
||||
return $this->orderby;
|
||||
}
|
||||
|
||||
function setLimit($limit = NULL)
|
||||
{
|
||||
if(!isset($limit))
|
||||
|
|
|
|||
|
|
@ -45,6 +45,16 @@ class OrderByColumn
|
|||
return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
|
||||
}
|
||||
|
||||
function getPureColumnName()
|
||||
{
|
||||
return is_a($this->column_name, 'Argument') ? $this->column_name->getPureValue() : $this->column_name;
|
||||
}
|
||||
|
||||
function getPureSortOrder()
|
||||
{
|
||||
return is_a($this->sort_order, 'Argument') ? $this->sort_order->getPureValue() : $this->sort_order;
|
||||
}
|
||||
|
||||
function getArguments()
|
||||
{
|
||||
$args = array();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue