Re: [CDBI] Updating data automatically after a search (trigger)
[prev]
[thread]
[next]
[Date index for 2006/02/01]
Kjell Arne wrote:
> Example with a session object:
> my $session = My::Session->search(pin => $pin) if $pin;
That gives you an iterator, not a session object. And if pin is the
primary key, it should use retrieve instead.
It also triggers a bug in perl caused by "my $foo = 1 if $bar"
constructs. Never assign to a lexical with a trailing if statement.
> I basically want something like this to happen in session.pm:
> sub search {
> my ($self, $DATA) = shift;
>
> $self->SUPER::search($DATA);
>
> // This will fail as $self is not blessed
> $self->last_active(time);
> $self->update();
> // **
> }
Make a method for it.
package My::Session;
sub find_by_pin {
my ($class, $pin) = @_;
return unless $pin;
my ($session) = $class->search(pin => $pin);
$session->last_active(time);
$session->update();
return $session;
}
- Perrin
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
|
|
Re: [CDBI] Updating data automatically after a search (trigger)
Perrin Harkins 15:08 on 01 Feb 2006
|