Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Version 1.1.32 under development

- Enh #4587: Add socket connection support to `CRedisCache` (mateusmetzker)
- Bug #4591: Fix deprecation in `CCaptchaAction` for PHP 8.1+ (rob006)
- Bug #4596: Fix transaction not commit when using dblib (icyzyy)

Version 1.1.31 April 10, 2025
--------------------------------
Expand Down
36 changes: 30 additions & 6 deletions framework/db/schema/mssql/CMssqlPdoAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,72 @@ public function lastInsertId ($sequence=NULL)
return $this->query('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS bigint)')->fetchColumn();
}

/**
* Checks if inside a transaction
*
* Checks if a transaction is currently active within the driver.
* This method always true if PHP below 5.4.0 to make it able to exec 'COMMIT TRANSACTION'
* @return boolean
*/
function inTransaction()
{
if(version_compare(PHP_VERSION,'5.4.0','>='))
return parent::inTransaction();
else
return true;
}

/**
* Begin a transaction
*
* Is is necessary to override pdo's method, as mssql pdo drivers
* does not support transaction
* does not support transaction for PHP below 5.4.0
*
* @return boolean
*/
#[ReturnTypeWillChange]
public function beginTransaction ()
{
$this->exec('BEGIN TRANSACTION');
if(version_compare(PHP_VERSION,'5.4.0','>='))
parent::beginTransaction();
else
$this->exec('BEGIN TRANSACTION');
return true;
}

/**
* Commit a transaction
*
* Is is necessary to override pdo's method, as mssql pdo drivers
* does not support transaction
* does not support transaction for PHP below 5.4.0
*
* @return boolean
*/
#[ReturnTypeWillChange]
public function commit ()
{
$this->exec('COMMIT TRANSACTION');
if(version_compare(PHP_VERSION,'5.4.0','>='))
parent::commit();
else
$this->exec('COMMIT TRANSACTION');
return true;
}

/**
* Rollback a transaction
*
* Is is necessary to override pdo's method, ac mssql pdo drivers
* does not support transaction
* does not support transaction for PHP below 5.4.0
*
* @return boolean
*/
#[ReturnTypeWillChange]
public function rollBack ()
{
$this->exec('ROLLBACK TRANSACTION');
if(version_compare(PHP_VERSION,'5.4.0','>='))
parent::rollBack();
else
$this->exec('ROLLBACK TRANSACTION');
return true;
}
}