# Retrieve all of the book records as book model objects and store in the
# stash where they can be accessed by the TT template
- $c->stash->{books} = [$c->model('MyAppDB::Books')->all];
+ $c->stash->{books} = [$c->model('DB::Books')->all];
# Set the TT template to use. You will almost always want to do this
# in your action methods.
This causes the Perl Debugger to enter "single step mode" when this command is
encountered (it has no effect when Perl is run without the C<-d> flag).
+B<NOTE:> The C<DB> here is the Perl Debugger, not the DB model.
+
To now run the Catalyst development server under the Perl debugger, simply
prepend C<perl -d> to the front of C<script/myapp_server.pl>:
development server will drop to the Perl debugger prompt:
MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:40):
- 40: $c->stash->{books} = [$c->model('MyAppDB::Books')->all];
+ 40: $c->stash->{books} = [$c->model('DB::Books')->all];
DB<1>
Next, list the methods available on our C<Book> model:
- DB<1> m $c->model('MyAppDB::Books')
+ DB<1> m $c->model('DB::Books')
()
(0+
(bool
We can also play with the model directly:
- DB<2> x ($c->model('MyAppDB::Books')->all)[1]->title
+ DB<2> x ($c->model('DB::Books')->all)[1]->title
SELECT me.id, me.title, me.rating FROM books me:
0 'TCP/IP Illustrated, Volume 1'
DB<3> x 4 $c->stash->{books}
0 ARRAY(0xa8f3b7c)
- 0 MyApp::Model::MyAppDB::Book=HASH(0xb8e702c)
+ 0 MyApp::Model::DB::Book=HASH(0xb8e702c)
'_column_data' => HASH(0xb8e5e2c)
'id' => 1
'rating' => 5