package My::Schema;
use base qw/DBIx::Class::Schema/;
-In this class you load your resultsource ("table", "model") classes, which
+In this class you load your result_source ("table", "model") classes, which
we will define later, using the load_classes() method. You can specify which
classes to load manually:
Note that L<DBIx::Class::Schema> does not cache connnections for you. If you
use multiple connections, you need to do this manually.
+To execute some sql statements on every connect you can pass them to your schema after the connect:
+
+ $schema->storage->on_connect_do(\@on_connect_sql_statments);
+
The simplest way to get a record is by primary key:
my $schema = My::Schema->connect( ... );
and return an instance of C<My::Schema::Album> that represents this
row. Once you have that row, you can access and update columns:
- $album->name('Physical Graffiti');
+ $album->title('Physical Graffiti');
my $title = $album->title; # holds 'Physical Graffiti'
If you prefer, you can use the C<set_column> and C<get_column>
We also provide a handy shortcut for doing a C<LIKE> search:
# Find albums whose artist starts with 'Jimi'
- my $rs = MyApp::DB::Album->search_like({ artist => 'Jimi%' });
+ my $rs = $schema->resultset('Album')->search_like({ artist => 'Jimi%' });
Or you can provide your own handmade C<WHERE> clause, like: