PHP Scripting Forums » PHP Classes Support Forum » Db_cart class Support forum

explination function remove_old_orders

(2 posts)

Tags:

Please support us by buying these products:

  1. User has not uploaded an avatar

    damen18
    Member

    He Olaf,

    Can you explain what you mean with this code? It's from db_cart_class.php on line 130

    function remove_old_orders($customer, $remove_only_zeros = true) {
    		if (RECOVER_ORDER && $customer > 0) {
    			$sql = sprintf("DELETE FROM %s WHERE open = 'y' AND customer = %d AND order_date < (NOW() - %d)", ORDERS, $customer, VALID_UNTIL * 86400);
    		} else {
    			$sql = sprintf("DELETE FROM %s WHERE open = 'y' AND order_date < (NOW() - %d)", ORDERS, VALID_UNTIL * 86400);
    		}
    		$sql .= ($remove_only_zeros) ? " AND customer = 0" : "";
    		mysql_query($sql);
    	}

    My question really is: how can i put $sql .= ($remove_only_zeros) ? " AND customer = 0" : ""; behind the other queries? I know it's one query, because the sql .= will make it one. But i want something like this (i know this isn't right)

    function remove_old_orders($customer, $remove_only_zeros = true) {
    		if (RECOVER_ORDER && $customer > 0) {
    			$sql = sprintf("DELETE FROM %s WHERE open = 'y' AND customer = %d AND order_date < (NOW() - %d)", ORDERS, $customer, VALID_UNTIL * 86400), ($remove_only_zeros) ? " AND customer = 0" : ";
    		} else {
    			$sql = sprintf("DELETE FROM %s WHERE open = 'y' AND order_date < (NOW() - %d)", ORDERS, VALID_UNTIL * 86400), ($remove_only_zeros) ? " AND customer = 0" : ";
    		}
    
    		mysql_query($sql);
    	}

    Is this possible?
    I hope you understand what i mean

    Thanx

    Posted 6 months ago #
  2. Hello,

    this function will remove old on orders from the database:

    if (RECOVER_ORDER && $customer > 0) {
    // remove order from one customer which are older than...
    } else {
    // remove ALL orders from customers which are older than...
    }
    // the next will remove all old orders from a system without using a customer ID
    $sql .= ($remove_only_zeros) ? " AND customer = 0" : "";

    I hope that makes it clear

    Posted 6 months ago #

RSS feed for this topic

Reply

You must log in to post.