From: Arthur Axel 'fREW' Schmidt Date: Sat, 12 Jun 2010 16:42:07 +0000 (-0500) Subject: add doc links X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2Fdbix-class-introduction-presentation.git;a=commitdiff_plain;h=78c1762eb75a0bf8c2be45e96550b09829b8b2d2 add doc links --- diff --git a/slideshow.html b/slideshow.html index f580d1b..8ad9bce 100644 --- a/slideshow.html +++ b/slideshow.html @@ -106,6 +106,9 @@

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

+
@@ -138,7 +141,7 @@

Responsive Community

    -
  • needed MSSQL Order by support, they helped me add support
  • +
  • needed MSSQL order-by support, they helped me add support
  • generally very welcoming of people willing to help
@@ -179,7 +182,7 @@ $sth->execute(

DBIC: Create

-
my $book = $book_rs->create({
+
my $book = $book_rs->create({
    title     => 'A book title',
    author_id => $author_id,
 });
@@ -213,15 +216,15 @@ $sth->execute(

DBIC: Read

-
my $book = $book_rs->find($book_id);
+
my $book = $book_rs->find($book_id);
 
-my $book = $book_rs->search({
+my $book = $book_rs->search({
    title => 'A book title',
-}, { rows => 1 })->next;
+}, { rows => 1 })->next;
 
 my @books = $book_rs->search({
    author => $author_id,
-})->all;
+})->all;
  • TMTOWTDI
@@ -253,7 +256,7 @@ $update->execute(

DBIC: Update

-
$book->update({
+
$book->update({
   title => 'New title',
 });
    @@ -273,7 +276,7 @@ $delete->execute($book_id);

DBIC: Delete

-
$book->delete;
+
$book->delete;
@@ -293,8 +296,8 @@ $delete->execute($book_id);

Convenience Methods

@@ -327,7 +330,7 @@ $delete->execute($book_id);
my $schema = Foo::Schema->connect(
    $dsn, $user, $pass
 );
-$schema->deploy
+$schema->deploy
 

See also: DBIx::Class::DeploymentHandler

@@ -337,8 +340,8 @@ $schema->deploy

DB -> Perl

package Foo::Schema;
 use strict; use warnings;
-use base 'DBIx::Class::Schema::Loader';
-__PACKAGE__->loader_options({
+use base 'DBIx::Class::Schema::Loader';
+__PACKAGE__->loader_options({
    naming => 'v7',
    debug  => $ENV{DBIC_TRACE},
 });
@@ -355,7 +358,7 @@ my $schema = Foo::Schema->connect(
    

Populate

Made for inserting lots of rows very quicky into database

-
$schema->populate([ Users =>
+
$schema->populate([ Users =>
    [qw( username password )],
    [qw( frew     >=4char$ )],
    [qw(      ...          )],
@@ -370,7 +373,7 @@ my $schema = Foo::Schema->connect(
    

Multicreate

Create an object and all of it's related objects all at once

-
$schema->resultset('Author')->create({
+
$schema->resultset('Author')->create({
    name => 'Stephen King',
    books => [{ title => 'The Dark Tower' }],
    address => {
@@ -398,18 +401,18 @@ my $schema = Foo::Schema->connect(
    

Extensible: DBIC::Helpers

-

Extensible: DBIC::TimeStamp

+

Extensible: DBIC::TimeStamp

  • Cross DB
  • set_on_create
  • @@ -420,7 +423,7 @@ my $schema = Foo::Schema->connect(

    Extensible: Kioku

      -
    • DBIx::Class::Schema::KiokuDB
    • +
    • DBIx::Class::Schema::KiokuDB
    • Kioku is the new hotness
    • Mix RDBMS with Object DB
    • beta ( == sexy )
    • @@ -428,7 +431,7 @@ my $schema = Foo::Schema->connect(
    -

    SQL::Abstract

    +

    SQL::Abstract

    my $resultset = $book_rs->search({
        name => { -like => "%$nick%" },
     });
    @@ -452,7 +455,7 @@ my $schema = Foo::Schema->connect(
    -

    ResultSet methods

    +

    ResultSet methods

    package MyApp::Schema::ResultSet::Book;
     use base 'DBIx::Class::ResultSet';
     sub good {
    @@ -479,7 +482,7 @@ sub cheap {
           
    • All searches should be ResultSet methods
    • Name has obvious meaning
    • -
    • current_source_alias helps things to work no matter what
    • +
    • current_source_alias helps things to work no matter what
    @@ -501,30 +504,30 @@ sub cheap {

    search_related

    my $score = $schema->resultset('User')
        ->search({'me.userid' => 'frew'})
    -   ->related_resultset('access')
    +   ->related_resultset('access')
        ->related_resultset('mgmt')
        ->related_resultset('orders')
        ->telephone
    -   ->search_related( shops => {
    +   ->search_related( shops => {
           'shops.datecompleted' => {
              -between => ['2009-10-01','2009-10-08']
           }
        })->completed
        ->related_resultset('rpt_score')
    -   ->get_column('raw_scores')
    +   ->get_column('raw_scores')
        ->first;
     

bonus rel methods

-
my $book = $author->create_related(
+
my $book = $author->create_related(
    books => {
       title => 'Another Discworld book',
    }
 );
 
-my $book2 = $pratchett->add_to_books({
+my $book2 = $pratchett->add_to_books({
    title => 'MOAR Discworld book',
 });
    @@ -534,17 +537,17 @@ my $book2 = $pratchett->add_to_books({

    Excellent Transaction Support

    -
    $schema->txn_do(sub {
    +
    $schema->txn_do(sub {
        ...
     });
     
    -my $guard = $schema->txn_scope_guard;
    +my $guard = $schema->txn_scope_guard;
     # ...
     $guard->commit;
     
    -$schema->txn_begin; # <-- low level
    +$schema->txn_begin; # <-- low level
     # ...
    -$schema->txn_commit;
    +$schema->txn_commit;
     
    @@ -554,8 +557,8 @@ $schema->txn_commit; use base 'DBIx::Class::Core'; use DateTime::Format::MySQL; # Result code here -__PACKAGE__->load_components('InflateColumn'); -__PACKAGE__->inflate_column( +__PACKAGE__->load_components('InflateColumn'); +__PACKAGE__->inflate_column( date_published => { inflate => sub { DateTime::Format::MySQL->parse_date( @@ -586,9 +589,9 @@ $book->update;
package Foo::Schema::Result::Book;
 use base 'DBIx::Class::Core';
 # Result code here
-__PACKAGE__->load_components('FilterColumn');
+__PACKAGE__->load_components('FilterColumn');
 
-__PACKAGE__->filter_column(
+__PACKAGE__->filter_column(
    length => {
       to_storage   => 'to_metric',
       from_storage => 'to_imperial',
@@ -600,7 +603,7 @@ sub to_imperial { $_[1] * 3.28 }
    
-

ResultSetColumn

+

ResultSetColumn

my $rsc = $schema->resultset('Book')
    ->get_column('price');
 $rsc->min;
@@ -612,16 +615,16 @@ $rsc->sum;
    

Aggregates

my @res = $rs->search({}, {
-   select   => [
+   select   => [
       'price',
       'genre',
       { max => price },
       { avg => price },
    ],
-   as       => [
+   as       => [
       qw(price genre max_price avg_price)
    ],
-   group_by => [qw(price genre)],
+   group_by => [qw(price genre)],
 });
 for (@res) {
    say $_->price . ' ' . $_->genre;
@@ -643,8 +646,8 @@ for (@res) {
    

HRI

$rs->search({}, {
-  result_class =>
-    'DBIx::Class::ResultClass::HashRefInflator',
+  result_class =>
+    'DBIx::Class::ResultClass::HashRefInflator',
 });
  • Easy on memory
  • @@ -655,7 +658,7 @@ for (@res) {
-

Subquery Support

+

Subquery Support

my $inside_query = $schema->resultset('Artist')
    ->search({
     name => [ 'Billy Joel', 'Brittany Spears' ],
@@ -667,7 +670,7 @@ my $rs = $schema->resultset('CD')->search({
    
-

Bare SQL w/ Placeholders

+

Bare SQL w/ Placeholders

$rs->update({
    # !!! SQL INJECTION VECTOR
    price => \"price + $inc",