Hello,
i try a employee database. When the user delete an employee all child entries should deleted too. I have seen, that the child entries will not be deleted. How to set up the app, that childs will be deleted too?
Thanks much, Kai
Delete Records with childs
-
- Veteran Member
- Posts: 45
- Joined: 2015-04-15 06:33
- Location: Hyderabad
- Contact:
Re: Delete Records with childs
Hi,
I'm sending the code for deleting the records with child tables.
I had two child tables for an parent table i place this code on parent table php file in hooks folder.
place the query in before delete function of employee.php and executes it it will work for you.
$sql="DELETE FROM `table1` WHERE `parent primary key`=".$selectedID; //here primary key means employee id
sql($sql,$eo);
$sql1="DELETE FROM `table2` WHERE `parent primary key`=".$selectedID;
sql($sql1,$eo);
I'm sending the code for deleting the records with child tables.
I had two child tables for an parent table i place this code on parent table php file in hooks folder.
place the query in before delete function of employee.php and executes it it will work for you.
$sql="DELETE FROM `table1` WHERE `parent primary key`=".$selectedID; //here primary key means employee id
sql($sql,$eo);
$sql1="DELETE FROM `table2` WHERE `parent primary key`=".$selectedID;
sql($sql1,$eo);
Re: Delete Records with childs
Thanks you very much.
Best regards, Kai
Best regards, Kai