Mysql trigger or coding in PHP? -


i have table hardware_description:

+------------------+--------------+------+-----+---------+----------------+ | field            | type         | null | key | default |          | +------------------+--------------+------+-----+---------+----------------+ | computer_id      | int(11)      | no   | pri | null    | auto_increment | | emp_id           | int(11)      | no   | mul | null    |                | | pc_type          | varchar(20)  | yes  |     | null    |                | | operating_system | varchar(20)  | yes  |     | null    |                | | product_key      | varchar(30)  | yes  |     | null    |                | | assign_date      | date         | yes  |     | null    |                | | dvd_rom          | varchar(20)  | yes  |     | null    |                | | cpu              | varchar(30)  | yes  |     | null    |                | | ip_address       | varchar(30)  | yes  |     | null    |                | | mac_address      | varchar(30)  | yes  |     | null    |                | | model_name       | varchar(30)  | yes  |     | null    |                | | model_number     | varchar(30)  | yes  |     | null    |                | | monitor          | varchar(30)  | yes  |     | null    |                | | processor        | varchar(30)  | yes  |     | null    |                | | product_name     | varchar(30)  | yes  |     | null    |                | | ram              | varchar(20)  | yes  |     | null    |                | | serial_number    | varchar(30)  | yes  |     | null    |                | | vendor_id        | varchar(30)  | yes  |     | null    |                |  

emp_id foreign key employees table.

when update particular row, want existing data row saved in table along timestamp of update action. now,

a) shall use php code (pdo transaction) first grab row & insert in table perform update query on particular row?

b) use trigger on table.

which process better practice & more efficient? there way of achieving this?

i have not used trigger in short career far can if better practice.

if can trigger, lot better use that.

the reason if reason forget write php code (in weird situation) - have missing, unrelated data - otherwise known orphaned data, not have corresponding row or set of rows.

here's link mysql documentation page triggers: http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -