In this section we will explore some additional capabilities offered
by DBIx::Class. Although these features have relatively little to do
-with Catalyst per-se, you will almost certainly want to take advantage
+with Catalyst per se, you will almost certainly want to take advantage
of them in your applications.
If you are following along in Ubuntu 8.10, you will need to
upgrade your version of
L<Catalyst::Model::DBIC::Schema|Catalyst::Model::DBIC::Schema>
-to 0.22 or higher. To do this, we can install directly from CPAN:
+to 0.23 or higher. To do this, we can install directly from CPAN:
$ cpan Catalyst::Model::DBIC::Schema
$ perl -MCatalyst::Model::DBIC::Schema -e \
'print "$Catalyst::Model::DBIC::Schema::VERSION\n"'
- 0.22
+ 0.23
Make sure you get version 0.22 or higher.
-B<Note:> Utuntu will automatically "do the right thing" and use the
+B<Note:> Ubuntu will automatically "do the right thing" and use the
module we installed from CPAN and ignore the older version we picked
up via the C<apt-get> command. If you are using a different
environment, you will need to make sure you are using v0.22 or higher
=head2 Create a ResultSet Class
-An often overlooked but extremly powerful features of DBIC is that it
+An often overlooked but extremely powerful features of DBIC is that it
allows you to supply your own subclasses of C<DBIx::Class::ResultSet>.
It allows you to pull complex and unsightly "query code" out of your
controllers and encapsulate it in a method of your ResultSet Class.
=cut
sub created_after {
- my ($self, $datetime) = @_;
-
- my $date_str = $self->_source_handle->schema->storage
- ->datetime_parser->format_datetime($datetime);
-
- return $self->search({
- created => { '>' => $date_str }
- });
+ my ($self, $datetime) = @_;
+
+ my $date_str = $self->_source_handle->schema->storage
+ ->datetime_parser->format_datetime($datetime);
+
+ return $self->search({
+ created => { '>' => $date_str }
+ });
}
1;
=cut
sub title_like {
- my ($self, $title_str) = @_;
+ my ($self, $title_str) = @_;
- return $self->search({
- title => { 'like' => "%$title_str%" }
- });
+ return $self->search({
+ title => { 'like' => "%$title_str%" }
+ });
}
We defined the search string as C<$title_str> to make the method more