@@ -313,6 +313,11 @@ PHP_FUNCTION(mysqli_commit)
313
313
}
314
314
MYSQLI_FETCH_RESOURCE_CONN (mysql , mysql_link , MYSQLI_STATUS_VALID );
315
315
316
+ if (!MYSQLI_IS_IN_TRANSACTION (mysql )) {
317
+ php_mysqli_report_error (NULL , 0 , "There is no active transaction" );
318
+ RETURN_FALSE ;
319
+ }
320
+
316
321
if (FAIL == mysqlnd_commit (mysql -> mysql , flags , name )) {
317
322
MYSQLI_REPORT_MYSQL_ERROR (mysql -> mysql );
318
323
RETURN_FALSE ;
@@ -523,12 +528,12 @@ PHP_FUNCTION(mysqli_execute_query)
523
528
524
529
if (FAIL == mysql_stmt_prepare (stmt -> stmt , query , query_len )) {
525
530
MYSQLI_REPORT_STMT_ERROR (stmt -> stmt );
526
-
531
+
527
532
close_stmt_and_copy_errors (stmt , mysql );
528
533
RETURN_FALSE ;
529
534
}
530
535
531
- /* The bit below, which is copied from mysqli_prepare, is needed for bad index exceptions */
536
+ /* The bit below, which is copied from mysqli_prepare, is needed for bad index exceptions */
532
537
/* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */
533
538
/* Get performance boost if reporting is switched off */
534
539
if (query_len && (MyG (report_mode ) & MYSQLI_REPORT_INDEX )) {
@@ -1420,6 +1425,10 @@ PHP_FUNCTION(mysqli_rollback)
1420
1425
}
1421
1426
MYSQLI_FETCH_RESOURCE_CONN (mysql , mysql_link , MYSQLI_STATUS_VALID );
1422
1427
1428
+ if (!MYSQLI_IS_IN_TRANSACTION (mysql )) {
1429
+ php_mysqli_report_error (NULL , 0 , "There is no active transaction" );
1430
+ RETURN_FALSE ;
1431
+ }
1423
1432
1424
1433
if (FAIL == mysqlnd_rollback (mysql -> mysql , flags , name )) {
1425
1434
MYSQLI_REPORT_MYSQL_ERROR (mysql -> mysql );
0 commit comments