Trigger other operation Perform other operation like Insert/Update data in other table directly (added in version 2.4)

Many times, you want to perform insert/update/delete operation in other table than main table also. For example, after entering employee leave date in "leaves" table, you might want to update total leaves taken by that employee in employee table also. One way is to do this is using the callback function, but you have to write quite a lines of code there. Now same thing can be achieved using the setTriggerOperation() function. You can specify tablename, column data, where data, type of operation and event to perform this operation.

  
                                     $pdocrud = new PDOCrud();
                $pdocrud->setTriggerOperation("student", array("total_attendance" => array("type" => "fixed", "val" => 10)), 
                         array(), "insert", "after_insert");
//                $pdocrud->setTriggerOperation("student", array("total_attendance" => array("type" => "last_insert_id")), 
//                          array(), "insert", "after_insert");
//                $pdocrud->setTriggerOperation("student", array("total_attendance" => array("type" => "array_data", "val" => "student_id")), 
//                          array(), "insert", "before_insert");
//                $pdocrud->setTriggerOperation("student", array("total_attendance" => array("type" => "fixed", "val" => 12)), 
//                          array("student_id"=> array("type" => "array_data", "val" => "student_id")), "update", "after_update");
                echo $pdocrud->dbTable("attendance")->render();
                                

Deprecated: Required parameter $field follows optional parameter $op in /home/javad/domains/javadfk.ir/public_html/pdocrud/script/classes/PDOCrud.php on line 924

Deprecated: Required parameter $task follows optional parameter $op in /home/javad/domains/javadfk.ir/public_html/pdocrud/script/classes/PDOCrud.php on line 924

Deprecated: Required parameter $totalrecords follows optional parameter $page in /home/javad/domains/javadfk.ir/public_html/pdocrud/script/classes/PDOCrudHelper.php on line 191

Attendance

Showing 1 to 2 of 2 entries

# Attendance id Status Student id Date Actions
1 3 2 1 2021-11-16
2 4 446 434 2021-11-16
# Attendance id Status Student id Date Actions