mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 16:52:16 +09:00
Add getAffectedRows() and getInsertID() to DB classes
쿼리 실행 후 affected rows, last insert ID 값을 받아올 수 있도록 DB 클래스에 관련 메소드를 추가함
This commit is contained in:
parent
8ef0d05ecb
commit
fa2b2914f2
5 changed files with 106 additions and 9 deletions
|
|
@ -37,6 +37,11 @@ class DBMssql extends DB
|
|||
'date' => 'nvarchar(14)',
|
||||
'float' => 'float',
|
||||
);
|
||||
|
||||
/**
|
||||
* Last statement executed
|
||||
*/
|
||||
var $last_stmt;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -242,6 +247,7 @@ class DBMssql extends DB
|
|||
$this->setError(print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
$this->last_stmt = $stmt;
|
||||
$this->param = array();
|
||||
|
||||
return $stmt;
|
||||
|
|
@ -988,6 +994,27 @@ class DBMssql extends DB
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of rows affected by the last query
|
||||
* @return int
|
||||
*/
|
||||
function getAffectedRows()
|
||||
{
|
||||
$stmt = $this->last_stmt;
|
||||
return $stmt ? sqlsrv_rows_affected($stmt) : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID generated in the last query
|
||||
* @return int
|
||||
*/
|
||||
function getInsertID()
|
||||
{
|
||||
$result = $this->_query('SELECT @@IDENTITY as id');
|
||||
$output = $this->_fetch($result);
|
||||
return $output->id ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DBParser
|
||||
* @param boolean $force
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue