Re: [Newbie] Cascade delete manually
| From: | Don Read | Date: | Thu, 01 May 2003 13:12:23 +0000 |
| Subject: | Re: [Newbie] Cascade delete manually | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145945@lists.php.net to get a copy of this message | ||
On 01-May-2003 Bobby Rahman wrote:
>
>
> So if mysql doesnt support cascade and nested queries can someone tell me
> how they get around deleting from more than one table. I suppose im
> really
> stuck on looping through one table and deleting all the rows.
>
> Here I go again:
>
> I can see the projid of the project wishes to delete and also I can see
> all the bugs which exist in that project by doing:
>
> select * from bug where bug.projid='$projid'
> But how do I do the logic for every bug that is within that project check
> to
> see if it has bug followups and if so delete them per bug untill all bug
> followups have been deleted then delete the bug then finally delete the
> project.
>
> DO I need to use some sort of loop to delete?
I get all the id's into an array then:
$list= implode(',', $ids);
$qry="DELETE FROM foo WHERE id IN ($list)";
mysql_query($qry);
$qry="DELETE FROM bar WHERE idref IN ($list)";
mysql_query($qry);
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.