Re: Deleting topics older than 2 hours?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Leif,


> Sounds to me like you didn't understand the question.  The table

=two sides to every story: either I'm too thick to understand, or you didn't
explain sufficiently - or both... see problem with necessarily open-ended
answer given below and consider...


> structure is something like:
> ____________topics_____________
> | id | forum | author | subject | posttime |
> -----------------------------
>
> _____________posts____________
> | id | topic | author | message | posttime|
> -----------------------------
>
> The problem is, if I run a query like (I know the query is probably
> wrong, I'm just writing it now):
> delete from topics where posttime + interval 2 hours < now()
> I would leave "orphan" posts inside of that topic.  I'm not sure how (or
> if it's even possible) to delete the posts as the topic is deleted.

=some RDBMSes implement "referential integrity"/a 'chaining process' built
from key-dependences, and thus when a row is DELETEd from topics, any
corresponding rows would be removed from posts as well.

=others, eg MySQL, do not, and thus unless MySQL's last DELETE format option
works sufficiently well, the best option might be two DELETE's: the first
per your suggestion above and the second to remove all entries in posts that
no longer join to a topics row.

=Regards,
=dn


> DL Neil wrote:
>
> >Sorry Leif, but CrystalBall v2.6 is currently unable to help.
> >The word WHERE features.
> >Show us the money - or second choice: the (erroneous) code...
> >=dn
> >
> >
> >
> >
> >>I'm trying to run a cron job to delete forum topics more than 2 hours
> >>old.  I know how to do that, but the problem is also deleting the posts
> >>in the topic at the same time.  Can someone shed some light on this,
> >>
> >>
> >please?
> >
> >
> >>--
> >>The above message is encrypted with double rot13 encoding.  Any
> >>
> >>
> >unauthorized attempt to decrypt it will be prosecuted to the full extent
of
> >the law.
> >
> >
> >>
> >>--
> >>PHP Database Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >>
> >>
> >
> >
> >
> >
>
> --
> The above message is encrypted with double rot13 encoding.  Any
unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.
>
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux