Trigger with button switch Trigger to save values in other tables of database on button click

You can use button switch with trigger to save values in other tables of database.

Button Switch : You can add extra action buttons to perform many operations like switch, url redirection etc. Below are example of how to add url action button and switch. URL action is for redirecting

to another website with some value and switch can be used for on/off operation (like approve/disapprove, publish/unpublish). Trigger: 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("login_status" => array("type" => "fixed", "val" => 1)),array(),
                                        "insert", "after_btn_switch_update");
                                $pdocrud->crudTableCol(array("first_name","last_name","no_of_adult","no_of_child","booking_amount","booking_status"));
                                $action = array("1"=>"0","0"=>"1");//action to be performed, like when value is 1 set it to 0
                                $text = array("1" => '',"0"=>'');
                                $attr = array("title"=>"Switch Button");
                                $pdocrud->enqueueBtnActions("btnswitch", $action, "btnswitch",$text,"booking_status", $attr);
                                echo $pdocrud->dbTable("bookroom")->render
                                

Bookroom

Showing 1 to 1 of 1 entries

# First name Last name No of adult No of child Booking amount Booking status Actions
1 jon Snow 2 2 100 1
# First name Last name No of adult No of child Booking amount Booking status Actions