O'Reilly logo

Catalyst 5.8 by Antano Solar John

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending a DBIx::Class model

A common occurrence is a situation in which your application has free reign over most of the database, but needs to use a few stored procedure calls to get to certain pieces of data. In that case, you'll want to create a normal DBIC schema, and then add methods for accessing the unusual data.

As an example, let's look back at the AddressBook application and imagine that for some reason we couldn't use DBIx::Class to access the user table, and instead need to write the raw SQL to return an array containing everyone's username. In AddressBook::Model::AddressDB, we just need to write a subroutine to do our work as follows:

package AddressBook::Model::AddressDB; // other code in the package sub get_users { my $self = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required