Personally, I would just increment the count of the file downloads in your database when you actually send the download to the user i.e. directly before you send the Location: header to initiatiate the file download. I really can't see the need for add.
php at all to be honest, it should just be a few lines that are initiated directly before the file download is initiated.
But then again, maybe I've missed something..it's very confusing code to me.