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 = shift; my $storage = $self->storage; return $storage->dbh_do( sub { my $self = shift; my $dbh = shift; my $sth = $dbh->prepare('SELECT username FROM user'); $sth->execute(); my @rows = @{$sth...