Page 1 of 1

delete record in a mysql table using php

Posted: Fri Jun 25, 2004 12:31 pm
by fanonimus
Hi!
I have a structure of many tables.
I have an array of arrays:

Code: Select all

$level_links = array();
$level_links [$i] = (table_name,$field_name,$table_name_link, $field_name_link);

ex:
$level_links = array();
$level_links= array();
$level_links[0] =array  ("country_table","id","company_table","country_id");

$level_links[1] =array("company_table","id","users_table","company_id");

$level_links[2] =array("users_table","id","users_data","user_id");

$level_links[3] =array("company_table","id","users_data","company_id");
country_table ----> company_table ----> users_table ----> users_data
country_table ----> company_table ---->users_data

There may be more elements of $level_links array.
I want to delete a record from table company. I should firstly, delete all users of this company and data of these users.
I think I need a tree algorithm....

How can I delete te record from company_table (a cascade delete) (something like in sqlserver structure of tables)?

Posted: Fri Jun 25, 2004 3:12 pm
by lostboy
The innodb table type (engine) can and does support Foreign Keys and Cascade deletes. Which matches what you are looking for...http://dev.mysql.com/doc/mysql/en/InnoD ... aints.html