I need help on a function in one off my plugins to update a table in model
on :September 28, 2021, 3:44 pm #529
I am using a plugin so users can sms there items to top off the search list. When payment is successful table item gets updated with publish date only.
I want on same transaction to also update column dt_expire with 30 days later.
original is:
public function moveTopByItemId( $item_id ) {
$aSet = array('dt_pub_date' => date('Y-m-d H:i:s'));
$aWhere = array('pk_i_id' => $item_id);
return $this->_update($this->getTable_Item(), $aSet, $aWhere);
}
What i need is to also have in same array to add 30 days on dt_expiration but i don't know how to put this in the same arrow... need help....
Something like this but then correctly coded :-)
public function moveTopByItemId( $item_id ) {
$aSet = array('dt_pub_date' => date('Y-m-d H:i:s'));
$aSet = array('dt_expiraration' => date('Y-m-d H:i:s')); +30 days
$aWhere = array('pk_i_id' => $item_id);
return $this->_update($this->getTable_Item(), $aSet, $aWhere);
}
Hope this can be achieved...thank you....
Re: I need help on a function in one off my plugins to update a table in model
on :September 29, 2021, 7:13 am #530
Re: I need help on a function in one off my plugins to update a table in model
on :September 29, 2021, 10:42 am #531
@calinbehtuk
Thank you but that is only to update 1 column and i need it top update 2 columns in same row at the same time. 1-dt_pub_date = today and 2-dt_expiration = today+30 days
I also gave you the wrong dt_expiraration :-) typo mistake
I tried:
public function moveTopByItemId( $item_id ) {
$aSet = array(
'dt_pub_date' => date('Y-m-d H:i:s'),
'dt_expiration' => date('Y:m:d H:i:s', strtotime('+30 days')
);
$aWhere = array('pk_i_id' => $item_id);
return $this->_update($this->getTable_Item(), $aSet, $aWhere);
}
But that gives errors....
Re: I need help on a function in one off my plugins to update a table in model
on :September 29, 2021, 11:26 am #532
Found it ... I forgot some )
Solved with:
public function moveTopByItemId( $item_id ) {
$aSet = array(
'dt_pub_date' => date('Y-m-d H:i:s'),
'dt_expiration' => date('Y:m:d H:i:s', strtotime('+30 days')));
$aWhere = array('pk_i_id' => $item_id);
return $this->_update($this->getTable_Item(), $aSet, $aWhere);
}
Thanks for your help (again)