Guest Posted May 3, 2006 Posted May 3, 2006 I wish to run a sql query on my databse Delete from Table: customers, Table: customers_info Where customers_info_id & customers_id Are the same and customers_info_number_of_logons = 0 This will remove all users that have not logged on, i would like to run this as a cron job as well but one thing at time Many thanks for your help Russell
Guest Posted May 3, 2006 Posted May 3, 2006 You can do: $customers_query = tep_db_query("select ci.customers_id from " . TABLE_CUSTOMERS_INFO . " ci where ci.customers_info_number_of_logons = 0"); whilie( $customers_array = tep_db_fetch_array($customers_query) ) { $customers_id = $customers_array['customers_info_id']; tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'"); tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'"); tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'"); } but you should backup your dbase first before experimenting, and you may need to add to the list other tables that using the customers id from contributions perhaps you have.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.