[Catalyst] Custom fields in a model

Greg Coates gcoates at csuchico.edu
Wed Jan 21 18:24:50 GMT 2009


I have a database table -- let's call it 'Contacts' that I'm accessing 
through a DBIx::Class model.  This table has two fields called 
'first_name' and 'last_name'.

Could I get some suggestion on the best way to add code to the model (or 
the schema) to allow me to add a custom field to the resultset without 
having an actual column in the database table?  I want to be able to 
access a field in the resultset called something like 'common_name'. 
This field would contain a concatenation of the first and last name 
fields for people and only the data from the last name for other 
entities like businesses.

Thanks!

Greg Coates



More information about the Catalyst mailing list