[Dbix-class] HOWTO: functions in update
Matt S Trout
dbix-class at trout.me.uk
Mon Jun 19 22:48:18 CEST 2006
Krzysztof Krzyzaniak wrote:
> Now I have something like;
>
> my $row = $c->model('SireDB::Article')->find($result->params->{'id'});
> if ($row->id == $result->params->{'id'})
> {
> $row->body($result->params->{'editarea'});
> $row->title($result->params->{'title'});
> $row->changed( localdate(time) );
> $row->update;
> }
> where localdate came from Class::Date and is equal current unix time
>
> but because of some reason I wanted use "database server time", I mean
> use "now()" sql function. How to do this?
>
> =pod
> this doesn't work because create literal
>
> update table changed = 'now()'
>
> instead of
>
> update table changed = now()
> =cut
> $row->changed( 'now()' );
$row->update(changed => \'now()');
$row->discard_changes; # re-fetch from DB
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list