The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::Custom::Order - Order by

SYNOPSIS

    # Result
    my $order = DBIx::Custom::Order->new;
    $order->prepend('title', 'author desc');
    my $order_by = "$order";
    

ATTRIBUTES

dbi

    my $dbi = $order->dbi;
    $order = $order->dbi($dbi);

DBIx::Custom object.

orders

    my $orders = $result->orders;
    $result = $result->orders(\%orders);

Parts of order by clause

METHODS

DBIx::Custom::Result inherits all methods from Object::Simple and implements the following new ones.

prepend

    $order->prepend('title', 'author desc');

Prepend order parts to orders.

You can pass array reference, which contain column name and direction. Column name is quoted properly

    # Column name and direction
    $order->prepend(['book-title']);
    $order->prepend([qw/book-title desc/]);

This is expanded to the following way.

    "book-title"
    "book-title" desc

to_string

    my $order_by = $order->to_string;

Create order by clause. If column name is duplicated, First one is used. to_string override stringification. so you can write the follwoing way.

    my $order_by = "$order";