I have a Model and want to insert something into the database.
One of the fields should add a number to the current value (timestamp)
$purchases = new PurchasesModel($this->connection);
$purchases->updates_until = 'updates_until + ' . $updates_included_time;
This does of course not work, so how can i do that?
The updates_until
field is formatted as timestamp (but since mysql 4.1 handled as datetime) in the database, $updates_included_time
is a int value which should be added to the timestamp.
Simply use the increments
method:
PurchasesModel::where('id', '=', 1)
->increment('updates_until', 'INTERVAL ' . $updates_included_time . ' SECOND');
You may change SECOND
to MINUTE
, or whatever suits you better.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.