delete record in a mysql table using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fanonimus
Forum Newbie
Posts: 1
Joined: Fri Jun 25, 2004 12:31 pm

delete record in a mysql table using php

Post 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)?
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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
Post Reply