fatfree
fatfree copied to clipboard
Suggestion: mapper->touch()
I think a function similar to the *nix touch
command would be useful in the mapper in cases when we need to update datetime
or timestamp
field in the original table.
For example, a user logs in and we can validate and then $user->touch('lastseen');
And on the next page load we can do it again..
Or for a product ordered we can $item->touch('lastorderdate');
There are many other use cases where this simple function would save some typing!
What do you think?
this will be very useful. +2
if you pack your entities into classes that extend mapper, you can add this method there. Don't see any needs to put that into the framework as its easy to code.
You could also create a table which has a field that updates the timestamp on every row update automatically:
CREATE TABLE user (
lastseen TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
True. The problem is that syntax is a bit different from a sql backend to another (Sqlite, Mysql, postgres..) I use a patched version that update automatically "created_at" & "updated_at" when the fields exist. it is a similar behaviour as Laravel, FuelPHP.
IMHO it is harmless to consider adding it.
i'm with @boussou on this. its harmless to consider adding it.
i'm with @KOTRET cuz "Many drops make a bucket, many buckets make a pond, many ponds make a lake, and many lakes make an ocean. (Percy Ross)" in future it all won't be fatfree anymore.
Any chance this will be added in the next release? It's been sitting here for years! :(