Page 1 of 1

Delete Records with childs

Posted: 2015-04-28 20:10
by SkayyHH
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

Re: Delete Records with childs

Posted: 2015-04-30 05:57
by Satya Kavala
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);

Re: Delete Records with childs

Posted: 2015-04-30 07:08
by SkayyHH
Thanks you very much.

Best regards, Kai