<p>The purpose of this talk is to show you as many features of
DBIx::Class in 40 minutes so that when you need to do something with
it later you will know what's possible</p>
+ <ul class="incremental">
+ <li>Note: links in slides are so you can find docs for what I'm talking about later</li>
+ </ul>
</div>
<div class="slide">
<div class="slide">
<h1>Responsive Community</h1>
<ul class="incremental">
- <li>needed MSSQL Order by support, they helped me add support</li>
+ <li>needed MSSQL order-by support, they helped me add support</li>
<li>generally very welcoming of people willing to help</li>
</ul>
</div>
<div class="slide">
<h1>DBIC: Create</h1>
-<pre>my $book = $book_rs->create({
+<pre>my $book = $book_rs-><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#create">create</a>({
title => 'A book title',
author_id => $author_id,
});</pre>
<div class="slide">
<h1>DBIC: Read</h1>
-<pre>my $book = $book_rs->find($book_id);
+<pre>my $book = $book_rs-><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#find">find</a>($book_id);
-my $book = $book_rs->search({
+my $book = $book_rs-><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#search">search</a>({
title => 'A book title',
-}, { rows => 1 })->next;
+}, { rows => 1 })-><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#next">next</a>;
my @books = $book_rs->search({
author => $author_id,
-})->all;</pre>
+})-><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#all">all</a>;</pre>
<ul class="incremental">
<li>TMTOWTDI</li>
</ul>
<div class="slide">
<h1>DBIC: Update</h1>
-<pre>$book->update({
+<pre>$book-><a href="http://search.cpan.org/perldoc?DBIx::Class::Row#update">update</a>({
title => 'New title',
});</pre>
<ul class="incremental">
<div class="slide">
<h1>DBIC: Delete</h1>
-<pre>$book->delete;</pre>
+<pre>$book-><a href="http://search.cpan.org/perldoc?DBIx::Class::Row#delete">delete</a>;</pre>
</div>
<div class="slide">
<div class="slide">
<h1>Convenience Methods</h1>
<ul class="incremental">
- <li>find_or_create</li>
- <li>create_or_update</li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#find_or_create">find_or_create</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#update_or_create">update_or_create</a></li>
</ul>
</div>
<pre>my $schema = Foo::Schema->connect(
$dsn, $user, $pass
);
-$schema->deploy
+$schema-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema#deploy">deploy</a>
</pre>
<p>See also: <a href="http://search.cpan.org/perldoc?DBIx::Class::DeploymentHandler">DBIx::Class::DeploymentHandler</a></p>
</div>
<p>DB -> Perl</p>
<pre>package Foo::Schema;
use strict; use warnings;
-use base 'DBIx::Class::Schema::Loader';
-__PACKAGE__->loader_options({
+use base '<a href="http://search.cpan.org/perldoc?DBIx::Class::Schema::Loader">DBIx::Class::Schema::Loader</a>';
+__PACKAGE__-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema::Loader::Base#CONSTRUCTOR_OPTIONS">loader_options</a>({
naming => 'v7',
debug => $ENV{DBIC_TRACE},
});
<div class="slide">
<h1>Populate</h1>
<p>Made for inserting lots of rows very quicky into database</p>
-<pre>$schema->populate([ Users =>
+<pre>$schema-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema#populate">populate</a>([ Users =>
[qw( username password )],
[qw( frew >=4char$ )],
[qw( ... )],
<div class="slide">
<h1>Multicreate</h1>
<p>Create an object and all of it's related objects all at once</p>
-<pre>$schema->resultset('Author')->create({
+<pre>$schema->resultset('Author')-><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#create">create</a>({
name => 'Stephen King',
books => [{ title => 'The Dark Tower' }],
address => {
<div class="slide">
<h1>Extensible: DBIC::Helpers</h1>
<ul class="incremental">
- <li>DBIC::Helper::ResultSet::IgnoreWantarray</li>
- <li>DBIC::Helper::ResultSet::Random</li>
- <li>DBIC::Helper::ResultSet::SetOperations</li>
- <li>DBIC::Helper::Row::JoinTable</li>
- <li>DBIC::Helper::Row::NumifyGet</li>
- <li>DBIC::Helper::Row::SubClass</li>
- <li>DBIC::Helper::Row::ToJSON</li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::IgnoreWantarray">DBIC::Helper::ResultSet::IgnoreWantarray</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::Random">DBIC::Helper::ResultSet::Random</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::SetOperations">DBIC::Helper::ResultSet::SetOperations</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::JoinTable">DBIC::Helper::Row::JoinTable</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::NumifyGet">DBIC::Helper::Row::NumifyGet</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::SubClass">DBIC::Helper::Row::SubClass</a></li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Helper::ResultSet::ToJSON">DBIC::Helper::Row::ToJSON</a></li>
</ul>
</div>
<div class="slide">
- <h1>Extensible: DBIC::TimeStamp</h1>
+ <h1>Extensible: <a href="http://search.cpan.org/perldoc?DBIx::Class::TimeStamp">DBIC::TimeStamp</a></h1>
<ul class="incremental">
<li>Cross DB</li>
<li>set_on_create</li>
<div class="slide">
<h1>Extensible: Kioku</h1>
<ul class="incremental">
- <li>DBIx::Class::Schema::KiokuDB</li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema::KiokuDB">DBIx::Class::Schema::KiokuDB</a></li>
<li>Kioku is the new hotness</li>
<li>Mix RDBMS with Object DB</li>
<li>beta ( == sexy )</li>
</div>
<div class="slide">
- <h1>SQL::Abstract</h1>
+ <h1><a href="http://search.cpan.org/perldoc?SQL::Abstract">SQL::Abstract</a></h1>
<pre>my $resultset = $book_rs->search({
name => { -like => "%$nick%" },
});</pre>
</div>
<div class="slide">
- <h1>ResultSet methods</h1>
+ <h1><a href="http://search.cpan.org/perldoc?DBIx::Class::Manual::Cookbook#Predefined_searches">ResultSet methods</a></h1>
<pre>package MyApp::Schema::ResultSet::Book;
use base 'DBIx::Class::ResultSet';
sub good {
<ul class="incremental">
<li>All searches should be ResultSet methods</li>
<li>Name has obvious meaning</li>
- <li>current_source_alias helps things to work no matter what</li>
+ <li><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#current_source_alias">current_source_alias</a> helps things to work no matter what</li>
</ul>
</div>
<h1>search_related</h1>
<pre>my $score = $schema->resultset('User')
->search({'me.userid' => 'frew'})
- ->related_resultset('access')
+ -><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#related_resultset">related_resultset</a>('access')
->related_resultset('mgmt')
->related_resultset('orders')
->telephone
- ->search_related( shops => {
+ -><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#search_related">search_related</a>( shops => {
'shops.datecompleted' => {
-between => ['2009-10-01','2009-10-08']
}
})->completed
->related_resultset('rpt_score')
- ->get_column('raw_scores')
+ -><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#get_column">get_column</a>('raw_scores')
->first;
</pre>
</div>
<div class="slide">
<h1>bonus rel methods</h1>
-<pre>my $book = $author->create_related(
+<pre>my $book = $author-><a href="http://search.cpan.org/perldoc?DBIx::Class::Relationship::Base#create_related">create_related</a>(
<strong>books</strong> => {
title => 'Another Discworld book',
}
);
-my $book2 = $pratchett->add_to_<strong>books</strong>({
+my $book2 = $pratchett-><a href="http://search.cpan.org/perldoc?DBIx::Class::Relationship::Base#add_to_$rel">add_to_<strong>books</strong></a>({
title => 'MOAR Discworld book',
});</pre>
<ul class="incremental">
<div class="slide">
<h1>Excellent Transaction Support</h1>
-<pre>$schema->txn_do(sub {
+<pre>$schema-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema#txn_do">txn_do</a>(sub {
...
});
-my $guard = $schema->txn_scope_guard;
+my $guard = $schema-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema#txn_scope_guard">txn_scope_guard</a>;
# ...
$guard->commit;
-$schema->txn_begin; # <-- low level
+$schema-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema#txn_begin">txn_begin</a>; # <-- low level
# ...
-$schema->txn_commit;
+$schema-><a href="http://search.cpan.org/perldoc?DBIx::Class::Schema#txn_commit">txn_commit</a>;
</pre>
</div>
use base 'DBIx::Class::Core';
use DateTime::Format::MySQL;
# Result code here
-__PACKAGE__->load_components('InflateColumn');
-__PACKAGE__-><strong>inflate_column</strong>(
+__PACKAGE__->load_components('<a href="http://search.cpan.org/perldoc?DBIx::Class::InflateColumn">InflateColumn</a>');
+__PACKAGE__-><strong><a href="http://search.cpan.org/perldoc?DBIx::Class::InflateColumn#inflate_column">inflate_column</a></strong>(
<strong>date_published</strong> => {
inflate => sub {
DateTime::Format::MySQL->parse_date(
<pre>package Foo::Schema::Result::Book;
use base 'DBIx::Class::Core';
# Result code here
-__PACKAGE__->load_components('FilterColumn');
+__PACKAGE__->load_components('<a href="http://search.cpan.org/perldoc?DBIx::Class::FilterColumn">FilterColumn</a>');
-__PACKAGE__-><strong>filter_column</strong>(
+__PACKAGE__-><strong><a href="http://search.cpan.org/perldoc?DBIx::Class::FilterColumn#filter_column">filter_column</a></strong>(
<strong>length</strong> => {
to_storage => 'to_metric',
from_storage => 'to_imperial',
</div>
<div class="slide">
- <h1>ResultSetColumn</h1>
+ <h1><a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSetColumn">ResultSetColumn</a></h1>
<pre>my $rsc = $schema->resultset('Book')
->get_column('price');
$rsc->min;
<div class="slide">
<h1>Aggregates</h1>
<pre>my @res = $rs->search({}, {
- select => [
+ <a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#select">select</a> => [
'price',
'genre',
{ max => price },
{ avg => price },
],
- as => [
+ <a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#as">as</a> => [
qw(price genre max_price avg_price)
],
- group_by => [qw(price genre)],
+ <a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#group_by">group_by</a> => [qw(price genre)],
});
for (@res) {
say $_->price . ' ' . $_->genre;
<div class="slide">
<h1>HRI</h1>
<pre>$rs->search({}, {
- result_class =>
- 'DBIx::Class::ResultClass::HashRefInflator',
+ <a href="http://search.cpan.org/perldoc?DBIx::Class::ResultSet#result_class">result_class</a> =>
+ '<a href="http://search.cpan.org/perldoc?DBIx::Class::ResultClass::HashRefInflator">DBIx::Class::ResultClass::HashRefInflator</a>',
});</pre>
<ul class="incremental">
<li>Easy on memory</li>
</div>
<div class="slide">
- <h1>Subquery Support</h1>
+ <h1><a href="http://search.cpan.org/perldoc?DBIx::Class::Manual::Cookbook#Subqueries">Subquery</a> Support</h1>
<pre>my $inside_query = $schema->resultset('Artist')
->search({
name => [ 'Billy Joel', 'Brittany Spears' ],
</div>
<div class="slide">
- <h1>Bare SQL w/ Placeholders</h1>
+ <h1><a href="http://search.cpan.org/perldoc?SQL::Abstract#Literal_SQL_with_placeholders_and_bind_values_(subqueries)">Bare SQL w/ Placeholders</a></h1>
<pre>$rs->update({
# !!! SQL INJECTION VECTOR
price => \"price + $inc",