Re: deleting carts

From: Date: Sun, 25 Feb 2001 04:53:19 +0000
Subject: Re: deleting carts
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6927@lists.php.net to get a copy of this message
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

« previous php.db (#6927) next »