Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Predefined actions

Events. Save new data in another table

Scroll Prev Next More

 

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

save_new_data_in_another_table_select_action

 

 

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

Data_Access_Layer

Database API

Database API: Insert        

Save old data in another table

Insert a record into another table

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software