[Catalyst] Nonsensical Problem with DBIx ResultSet
Kyle Hall
kyle.m.hall at gmail.com
Thu Jul 8 14:57:06 GMT 2010
Hello all,
I'm the developer of a FOSS kiosk management system, Libki. I'm in the
early stages of a complete rewrite using Catalyst for the web-based
administration interface. This is my first time using Catalyst, but I'm very
excited by the possibilities! I'm having a very strange issue with my
resultsets. For example, I have three tables, a users table, a clients
table, and a sessions table that connects the user to a client.
I grab my users from the database, with any session/client data if the user
is currently logged in to a client kiosk. I am prefetching the session and
client table data.
my $user_rs =3D $c->model('DB::User')->search( {}, { prefetch =3D> { sessio=
n =3D>
'client' } } );
Now I want to loop through it.
my $row =3D 0;
my @row_data;
while ( my $user =3D $user_rs->next() ) {
my $user_id =3D $user->id;
warn $user->session->client->clientname;
my $single_row =3D {
cell =3D> [
$user->id,
$user->username,
$user->minutes,
$user->status,
$user->is_troublemaker,
$user->session->client->clientname;
]
};
push( @row_data, $single_row );
}
Now, if I try to access any of the other tables, I get an error:
[error] Caught exception in LibkiServer::Controller::Admin::REST->users
"Can't call method "client" on an undefined value at
/home/libki/LibkiServer/script/../lib/LibkiServer/Controller/Admin/REST.pm
line 40."
I don't know why I get this error, but the really crazy part is *the warn
still works*:
Client Name: testclient1 at
/home/libki/LibkiServer/script/../lib/LibkiServer/Controller/Admin/REST.pm
line 40.
If anyone can help me out, I'd be eternally grateful.
Thanks,
Kyle
http://www.kylehall.info
Mill Run Technology Solutions ( http://millruntech.com )
Crawford County Federated Library System ( http://www.ccfls.org )
Meadville Public Library ( http://www.meadvillelibrary.org )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100708/c7903=
145/attachment.htm
More information about the Catalyst
mailing list