Save new data in another table action allows copying added or modified data to another table. This table should be a part of the project.
Available in the following events:
•Add page: Before record added
•Edit page: Before record updated
Example 1. Direct SQL query
//********** Save new data in another table ************
// note: text field values need to be wrapped by single quotes
$sql = "INSERT INTO copy_of_cars (make, model, price) values (";
$sql .= "'".$values["make"]."',";
$sql .= "'".$values["model"]."',";
$sql .= $values["price"];
$sql .= ")";
DB::Query($sql);
Example 2. Database API
//********** Save new data in another table ************
$data = array();
$data["make"] = $values["make"];
$data["model"] = $values["model"];
$data["price"] = $values["price"];
DB::Insert("copy_of_cars", $data );
See also
•Save old data in another table
•Insert a record into another table