C:\xampp\htdocs\dev\tw_portal_2023\vendor\doctrine\dbal\src\Driver\PDO\PDOException.php(20): There is no active transaction
When i try to add new entry, after click add button this above error is showing
Master/Detail-Add - There is no active transaction (v2023)
-
- User
- Posts: 48
Master/Detail-Add - There is no active transaction (v2023)
-
- User
- Posts: 48
This is the debug code.
#0 C:\xampp\htdocs\athira\dev\tw_portal_2023\vendor\doctrine\dbal\src\Driver\PDO\Connection.php(137): Doctrine\DBAL\Driver\PDO\PDOException::new(Object(PDOException))
#1 C:\xampp\htdocs\athira\dev\tw_portal_2023\vendor\doctrine\dbal\src\Connection.php(1516): Doctrine\DBAL\Driver\PDO\Connection->rollBack()
#2 C:\xampp\htdocs\athira\dev\tw_portal_2023\models\TechWrtgInputAdd.php(1985): Doctrine\DBAL\Connection->rollBack()
#3 C:\xampp\htdocs\athira\dev\tw_portal_2023\models\TechWrtgInputAdd.php(603): PHPMaker2023\technical_writing_automation_1v00_23\TechWrtgInputAdd->addRow(NULL)
#4 C:\xampp\htdocs\athira\dev\tw_portal_2023\controllers\ControllerBase.php(50): PHPMaker2023\technical_writing_automation_1v00_23\TechWrtgInputAdd->run()
-
- User
- Posts: 9384
arbei wrote:
If it is raised by your server event, post your complete code for discussion.
If you have Row_Inserting and/or Row_Inserted server event, you may post for discussion.
If not, you may provide more information:
- What is the database type? If MySQL, what is the engine of the table? Is it InnoDB?
- Are you doing Master/Detail-Add/Copy for the table?
- Post your table schema of the master table (and detail tables, if any) so other users can try to reproduce.
Notes:
- If InnoDB, transaction is supported. Check the table schema of the table and make sure the engine is not set as MyISAM (which does not support transaction).
- The error said no active transaction, but the transaction should be started by
$conn->beginTransaction()
in TechWrtgInputAdd.php (check source code before line 1985). If you have no Row_Inserting or Grid_Inserting server event for the detail table, then the transaction should be intact and you should be able to rollback. You better check if there is anything preventing the transaction from working. - Make sure no other server events called
$conn->commit()
or$conn->rollback()
otherwise there is no more active transaction.
-
- User
- Posts: 48
MySql and InnoDB
For master table:
public function rowInserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
$userid = CurrentUserID();
$slno = ExecuteScalar("SELECT MAX(SLNO) FROM tech_wrtg_input");
if (strlen($slno) == 0)
$slno = 1;
Execute("ALTER TABLE tech_wrtg_input auto_increment =".$slno);
$rsnew['VERIFIER_STATUS'] = 'Pending';
$rsnew['APPROVAL_STATUS'] = 'Pending';
$dept = CurrentUserDept();
$tw_arr_emp = array(1277,2374,2224);
if ($dept != 'ADM' and $dept != 'HDD' and $dept != 'SDG' and $dept != 'PDN' and $dept != 'PRJ' and !in_array($userid, $tw_arr_emp)){
$this->CancelMessage = "Access Denied. Please contact QAC TW team member.";
return false;
}
$_SESSION['po_attachment'] = $rsnew['PO_FILE'];
if ($rsnew['ACCESS_GIVEN'] == 'No') {
$this->CancelMessage = "You cannot raise this request until access is given to TW Team.";
return false;
}
// Insert document type based on child table
if (isset($_GET['showdetail'])) {
$_SESSION['tableName'] = $_GET['showdetail'];
}
$tableName = $_SESSION['tableName'];
if (strpos($tableName, 'tech_wrtg_prj_doc') !== false)
$rsnew['DOCUMENT_TYPE'] = 'Project Document';
if (strpos($tableName, 'tech_wrtg_pdn_doc') !== false)
$rsnew['DOCUMENT_TYPE'] = 'Production Document';
/*// Validate Document Type to be prepared field If Project Document
if (strpos($tableName, 'tech_wrtg_prj_doc') !== false and strlen($rsnew['CHKL_TYPE']) == 0) {
$this->CancelMessage = "Please select Document Type to be prepared field.";
return false;
}*/
return TRUE;
}
// Row Inserted event
public function rowInserted($rsold, &$rsnew) {
//echo "Row Inserted"
$_SESSION['viewpageredirct'] = "RedirectViewPage";
}
after i commented this line it working fine,
Execute("ALTER TABLE tech_wrtg_input auto_increment =".$slno);
How i execute that query?