mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
Update API for 3.2 release
See https://github.com/silverstripe/silverstripe-framework/pull/4288
This commit is contained in:
parent
dd23af4278
commit
be2e9469fd
@ -117,28 +117,25 @@ class SQLServerConnector extends DBConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR) {
|
public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR) {
|
||||||
// Check if we should only preview this query
|
// Reset state
|
||||||
if ($this->previewWrite($sql)) return;
|
$this->lastAffectedRows = 0;
|
||||||
|
|
||||||
|
// Run query
|
||||||
$parsedParameters = $this->parameterValues($parameters);
|
$parsedParameters = $this->parameterValues($parameters);
|
||||||
|
if(empty($parsedParameters)) {
|
||||||
// Benchmark query
|
$handle = sqlsrv_query($this->dbConn, $sql);
|
||||||
$dbConn = $this->dbConn;
|
|
||||||
$handle = $this->benchmarkQuery($sql, function($sql) use($dbConn, $parsedParameters) {
|
|
||||||
if(empty($parsedParameters)) {
|
|
||||||
return sqlsrv_query($dbConn, $sql);
|
|
||||||
} else {
|
|
||||||
return sqlsrv_query($dbConn, $sql, $parsedParameters);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if($handle) {
|
|
||||||
$this->lastAffectedRows = sqlsrv_rows_affected($handle);
|
|
||||||
} else {
|
} else {
|
||||||
|
$handle = sqlsrv_query($this->dbConn, $sql, $parsedParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for error
|
||||||
|
if(!$handle) {
|
||||||
$this->databaseError($this->getLastError(), $errorLevel, $sql, $parsedParameters);
|
$this->databaseError($this->getLastError(), $errorLevel, $sql, $parsedParameters);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report result
|
||||||
|
$this->lastAffectedRows = sqlsrv_rows_affected($handle);
|
||||||
return new SQLServerQuery($this, $handle);
|
return new SQLServerQuery($this, $handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user