Re: [PHP-DB] deleting carts
Although it is probably easiest for you to manage this with php, It makes more sense to me to write a script that is managed by cron (php if you really want) that is executed on a regular basis w/out affecting any users browser latency. If each customer has to wait a little longer, you're going to have less happy customers. The latency should be trivial, but "should" usually means gottcha. For whatever database your using, there should be a simple solution for executing scripts which you could place in a cron job. PHP should be overkill. However, if you insist on PHP, you can compile up the cgi module which doesn't require a browser. Others have suggested executing a php script with lynx via cron. Although... Firing up lynx to talk to apache to execute a php script, to issue a database command sounds like a lot of overkill to me. Especially when this is simpler to create and maintain: $ mysql --execute "delete from carts where timestamp > now() + 36000" -- Have fun, -Joe ""Jorge Santos"" <[EMAIL PROTECTED]> wrote in message 002e01c09ee4$f1754360$[EMAIL PROTECTED]">news:002e01c09ee4$f1754360$[EMAIL PROTECTED]... > Hi Nick, > > Of course it's possible. Anything is possible. Simply generate a simple PHP > script that will be executed from the command line which is called from a > cron. The PHP script would simple delete any records where (current date) - > (your date_added) >= 90 days. > > On the other hand, on the shopping cart that I wrote, I did it another way; > instead of creating a separate script and additional external components > (the cron for example), simple create 1 function that holds the > functionality needed to delete the old records. Then just call the function > each time your cart script is called. There's no reason to create a cron to > delete records because you can have the shopping cart script do it > automatically... > > > Hope this helps, > Jorge > [EMAIL PROTECTED] > - Original Message ----- > From: Nicholas W. Miller <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Saturday, February 24, 2001 11:31 PM > Subject: [PHP-DB] deleting carts > > > > I am developing a shopping cart style e-commerce web site. I have a > > table called carts that holds users' cart items ... so one user may > > have several entries in this table: > > > > ++--+--+-+-+---+ > > | Field | Type | Null | Key | Default | Extra | > > ++--+--+-+-+---+ > > | cust_id| int(11) | | | 0 | | > > | item_id| int(11) | YES | | NULL| | > > | qty| tinyint(4) | YES | | NULL| | > > | price | float(10,2) | YES | | NULL| | > > | date_added | timestamp(6) | YES | | NULL| | > > ++--+--+-+-+---+ > > > > I would like to write a PHP script that I will cron which will delete > > all items belonging to a user if their most recent item is over 90 > > days old. > > > > Is this possible? > > > > Nick > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] deleting carts
Hi Nick, Of course it's possible. Anything is possible. Simply generate a simple PHP script that will be executed from the command line which is called from a cron. The PHP script would simple delete any records where (current date) - (your date_added) >= 90 days. On the other hand, on the shopping cart that I wrote, I did it another way; instead of creating a separate script and additional external components (the cron for example), simple create 1 function that holds the functionality needed to delete the old records. Then just call the function each time your cart script is called. There's no reason to create a cron to delete records because you can have the shopping cart script do it automatically... Hope this helps, Jorge [EMAIL PROTECTED] - Original Message - From: Nicholas W. Miller <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, February 24, 2001 11:31 PM Subject: [PHP-DB] deleting carts > I am developing a shopping cart style e-commerce web site. I have a > table called carts that holds users' cart items ... so one user may > have several entries in this table: > > ++--+--+-+-+---+ > | Field | Type | Null | Key | Default | Extra | > ++--+--+-+-+---+ > | cust_id| int(11) | | | 0 | | > | item_id| int(11) | YES | | NULL| | > | qty| tinyint(4) | YES | | NULL| | > | price | float(10,2) | YES | | NULL| | > | date_added | timestamp(6) | YES | | NULL| | > ++--+--+-+-+---+ > > I would like to write a PHP script that I will cron which will delete > all items belonging to a user if their most recent item is over 90 > days old. > > Is this possible? > > Nick > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] deleting carts
At 11:31 PM 2/24/01 -0500, Nicholas W. Miller wrote: >I am developing a shopping cart style e-commerce web site. I have a >table called carts that holds users' cart items ... so one user may >have several entries in this table: > >++--+--+-+-+---+ >| Field | Type | Null | Key | Default | Extra | >++--+--+-+-+---+ >| cust_id| int(11) | | | 0 | | >| item_id| int(11) | YES | | NULL| | >| qty| tinyint(4) | YES | | NULL| | >| price | float(10,2) | YES | | NULL| | >| date_added | timestamp(6) | YES | | NULL| | >++--+--+-+-+---+ > >I would like to write a PHP script that I will cron which will delete >all items belonging to a user if their most recent item is over 90 >days old. > >Is this possible? What database? Assuming an sql type you do a select custid, max(date_added) (I do most my dates as just ints of unix timestamps) group by custid having max(date_added) > (timestamp of 90 days ago). as you select them call a function that passes custids that come up, and the function deletes where custid = thevaluepassed. = "To dwell within Samsara, however, is to be subject to the works of those mighty among dreamers." - Mahasamatman, in Zelazny's "Lord of Light" Andrew Apold -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] deleting carts
I am developing a shopping cart style e-commerce web site. I have a table called carts that holds users' cart items ... so one user may have several entries in this table: ++--+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | ++--+--+-+-+---+ | cust_id| int(11) | | | 0 | | | item_id| int(11) | YES | | NULL| | | qty| tinyint(4) | YES | | NULL| | | price | float(10,2) | YES | | NULL| | | date_added | timestamp(6) | YES | | NULL| | ++--+--+-+-+---+ I would like to write a PHP script that I will cron which will delete all items belonging to a user if their most recent item is over 90 days old. Is this possible? Nick -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]