Unless you go plain SQL you'll have to do that on the PHP side (of the force)
1 $user->expire = new DateTime('@'.strtotime('+3 days'));
I can't seem to find how to override the default created_at.
For example, I want to set created_at to be something earlier and did a
$checkin->created_at = new DateTime($string);
print_r($checkin) returns
Checkin Object
(
[errors] =>
[attributes:ActiveRecord\Model:private] => Array
(
[created_at] => ActiveRecord\DateTime Object
(
[model:ActiveRecord\DateTime:private] => Checkin Object
RECURSION
[attribute_name:ActiveRecord\DateTime:private] => created_at
[date] => 2011-05-21 21:19:03
[timezone_type] => 1
[timezone] => +00:00
)
)
but when it saves, it still saves using NOW or something like that.
created_at
and updated_at
are set auto-magically.
- https://github.com/kla/php-activerecord/blob/master/lib/Model.php#L1091-1103
- https://github.com/kla/php-activerecord/blob/master/lib/Table.php#L89
(1-3/3)
Subject: Support for setting SQL expressions
I know that you can build your own query and use SQL functions like NOW() in them, but is there any support for settings those values via simple setter methods. For example:
$user = User::find_by_email('');
$user->expire = "`NOW()+INTERVAL 3 DAY`";
$user->save();
Just a suggestion, thanks.