@@ -29,48 +29,72 @@ public function lastInsertId ($sequence=NULL)
2929 return $ this ->query ('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS bigint) ' )->fetchColumn ();
3030 }
3131
32+ /**
33+ * Checks if inside a transaction
34+ *
35+ * Checks if a transaction is currently active within the driver.
36+ * This method always true if PHP below 5.4.0 to make it able to exec 'COMMIT TRANSACTION'
37+ * @return boolean
38+ */
39+ function inTransaction ()
40+ {
41+ if (version_compare (PHP_VERSION ,'5.4.0 ' ,'>= ' ))
42+ return parent ::inTransaction ();
43+ else
44+ return true ;
45+ }
46+
3247 /**
3348 * Begin a transaction
3449 *
3550 * Is is necessary to override pdo's method, as mssql pdo drivers
36- * does not support transaction
51+ * does not support transaction for PHP below 5.4.0
3752 *
3853 * @return boolean
3954 */
4055 #[ReturnTypeWillChange]
4156 public function beginTransaction ()
4257 {
43- $ this ->exec ('BEGIN TRANSACTION ' );
58+ if (version_compare (PHP_VERSION ,'5.4.0 ' ,'>= ' ))
59+ parent ::beginTransaction ();
60+ else
61+ $ this ->exec ('BEGIN TRANSACTION ' );
4462 return true ;
4563 }
4664
4765 /**
4866 * Commit a transaction
4967 *
5068 * Is is necessary to override pdo's method, as mssql pdo drivers
51- * does not support transaction
69+ * does not support transaction for PHP below 5.4.0
5270 *
5371 * @return boolean
5472 */
5573 #[ReturnTypeWillChange]
5674 public function commit ()
5775 {
58- $ this ->exec ('COMMIT TRANSACTION ' );
76+ if (version_compare (PHP_VERSION ,'5.4.0 ' ,'>= ' ))
77+ parent ::commit ();
78+ else
79+ $ this ->exec ('COMMIT TRANSACTION ' );
5980 return true ;
6081 }
6182
6283 /**
6384 * Rollback a transaction
6485 *
6586 * Is is necessary to override pdo's method, ac mssql pdo drivers
66- * does not support transaction
87+ * does not support transaction for PHP below 5.4.0
6788 *
6889 * @return boolean
6990 */
7091 #[ReturnTypeWillChange]
7192 public function rollBack ()
7293 {
73- $ this ->exec ('ROLLBACK TRANSACTION ' );
94+ if (version_compare (PHP_VERSION ,'5.4.0 ' ,'>= ' ))
95+ parent ::rollBack ();
96+ else
97+ $ this ->exec ('ROLLBACK TRANSACTION ' );
7498 return true ;
7599 }
76100}
0 commit comments