MySQL – Auto delete a record in table when date is expired

It’s possible by Event Scheduler

CREATE EVENT IF NOT EXISTS `[database_name]`.`[event_name]` ON SCHEDULE EVERY 30 SECOND
 DO
 DELETE FROM `[database_name]`.`[table_name]` WHERE `create_on` < NOW()-INTERVAL 60 SECOND;

The above run for every 30 seconds and will delete the records where created_on is less then 60 seconds on every trigger of this event.

Make sure Event Scheduler should be enabled on your server.

 SET GLOBAL event_scheduler = ON;
Advertisements

Codeigniter 2 on IIS with web.config file

<code><?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
 <rewrite>
 <rules>
 <rule name="Rewrite to index.php">
 <match url="index.php|robots.txt|images|test.php" />
<action type="None" />
</rule>
<rule name="Rewrite CI Index">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
</code>

 
Ref : http://codeigniter.com/forums/viewthread/91954