This topic is locked
[SOLVED]

Mysqli commint and rollback

2/1/2022 7:52:42 AM
PHPRunner Tips and Tricks
R
Rashid author

Hi everyone. I am using phprunner 10.6 and would like to know how to use commit and rollback on MySQL for accounting system. In the phprunner code, I am the API query recomended by phprunner and I don't to use direct connection if possible or create external files for this purpose. Many thanks.

Admin 2/1/2022

I guess you can just execute COMMIT or ROLLBACK commands using Database API:
https://xlinesoft.com/phprunner/docs/db_exec.htm

R
Rashid author 2/2/2022

Thanks Admin;
Your link with this code has helped me:

global $cman;
try{

$sql = "INSERT INTO myTable VALUES('value1','value2')";
$connection = $cman->byName("myConn");

$connection->EXEC("START TRANSACTION;");

$connection->exec($sql);

$connection->EXEC("COMMIT;");

}catch (Exception $e) {

$connection->EXEC("ROLLBACK;");

}