[CDBI] has_a and null foreign keys

Arshavir Grigorian grigorian at gmail.com
Tue Apr 10 03:50:07 BST 2007


I have 2 tables that are related to each other through has_a relationship in
Class::DBI. However, it can happen that a record in table1 does not have the
foreign key  for table2 populated. In this situation, if I try to call
My::Class->retrieve(id => $id)->foreign_key->column_in_table2(), I get an
error because foreign_key() didn't return a valid object and
column_in_table2() fails. Should I be trying to check whether
->foreign_key() returns a valid object and only then call column_in_table2()
or is there another way? Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/pipermail/classdbi/attachments/20070409/ac093312/attachment-0001.html

More information about the ClassDBI mailing list