CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2018|Reply: 6

PHP Autodelete function

[Copy link]
Post time 9-4-2007 08:50 AM | Show all posts |Read mode
hi guys,
miss nak tanya lagi..ok like this..
miss nak wat autodelete function based on date..data akan miss delete selepas sebulan..ok miss boleh set php script tu tp masalahnya nak make it that script working kiter kena bukak page tu kan..hmm ada tak cara klau miss hidden page tu n make it autodelete? x yah bukak page tp dia boleh delete?

or korang ada cara lain?

thanks in advance.
Reply

Use magic Report


ADVERTISEMENT


Post time 9-4-2007 01:37 PM | Show all posts
buat je bash file kat /etc/cron.monthly
Reply

Use magic Report

Post time 12-4-2007 03:49 PM | Show all posts

Reply #2 BorderManager's post

ermmm susah gak tuh.. kene wat /etc/cron.monthly eh??
Reply

Use magic Report

Post time 12-4-2007 04:45 PM | Show all posts

Reply #3 liverpoolfctv's post

cron job tu autorun utk linux, aku buat daily dan monthly backup guna fail je.........so xde isu ko masuk webpage ke tak........
Reply

Use magic Report

Post time 14-4-2007 12:12 PM | Show all posts
ataupun ...

takyah buat automatic precise in time ..

just buat satu file php ..

yg dalam tu ada


  1. $keeptime = time()-60*60*24*30;
  2. $sql = " delete from x where addtime<$keeptime"
  3. mysql_query($sql);
Copy the Code


include je file di atas kat index.php ataupun file login ke dll ..  include seawal mungkin

so bila org nak guna je system, baru dia "autodelete"...
maksudnya .. org lain yg tolong u "purge" old data

unless ...

kalau ada application lain yg check database tu .. but again, application tu boleh select based kepada $keeptime ..

web application ni tak perlu realtime giler babi .. pseudo realtime dah ok ..

btw,

teknik ni boleh menyebabkan application slow(extreme cases, high trafic dan high data) ..

maybe kena optimize sket, yakni call delete tu sekali sehari/sejam sahaja .. ataupun just create field utk tag samada row tu deleted atau tidak .. then manually delete and optimize table ..


contohnya ..


  1. // optimized pseudo auto-delete, i tak check betul ke idak, ni pseudo algo je
  2. $lastdeleted=0;
  3. if(file_exists($namatagfile) {
  4.    $lastdeleted = str2int(file_get_content($namatagfile));
  5. }
  6. if($lastdeleted<time()-$sejam) {
  7.    $sql = "delete from table where time<xxx";
  8.     mysql_query($sql);
  9.     $f = fopen($namatagfile, "wt");
  10.     fprintf($f, "%d", time());
  11.     fclose($f);
  12. }
  13. // settle
Copy the Code


begitulah adanya
Reply

Use magic Report

Post time 29-5-2007 02:20 AM | Show all posts
memang kene wat cron job..sebab yang ni lebih kurang cam scheduler..lepas satu masa...dia akan run dan delete data automatically..so kene wat camni..takde cara lain...sebab yang saya tahu dan pernah buat tu je la...

[ Last edited by  mygirlz at 29-5-2007 09:39 PM ]
Reply

Use magic Report

Follow Us
IblisCun This user has been deleted
Post time 17-6-2007 02:10 PM | Show all posts
..................................................................................
.................................................................................

[ Last edited by  blackpearl at 19-6-2007 09:27 PM ]
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT


Forum Hot Topic

 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

12-2-2025 06:49 AM GMT+8 , Processed in 0.051250 second(s), 21 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list