*

mwindey

  • ****
  • 128 posts
Delete empty rows in sms_premium_expire
« on: August 04, 2021, 11:45:49 AM »
In sms_premium_expire empty fields are kept from premiums that have been expired. Normally no problem because they don't take up much space in DB, but because I want to request the expire_date of an item to echo in user_items, it gives an error if the item_id occurs 2 times in the table.
I want to delete the table every time the item premium expires.
In index of sms-payment folder there is a line that clears the logs and modifies that table t_item.
Code: [Select]
function sp_change_premium( $item_id, $premium, $date = NULL) {
  ModelSP::newInstance()->updatePremiumByItemId( $item_id, $premium ); // change b_premium to t_item table

Can I modify this line so that the table is also removed in t_sms_premium_expire?

Code: [Select]
function sp_change_premium( $item_id, $premium, $date = NULL) {
  ModelSP::newInstance()->updatePremiumByItemId( $item_id, $premium ); // change b_premium to t_item table
$sql ="DELETE FROM oc_t_item_sms_premium_expire WHERE expire_date = ' ' or expire_date is null";

Marc

*

MB Themes

Re: Delete empty rows in sms_premium_expire
« Reply #1 on: August 04, 2021, 12:45:28 PM »
@mwindey
Wouldn't be simpler to put that condition into function that gets expire date from database?
In this case you should have cleaning function running daily (via cron) that will clean-up redundant rows in database.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots