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

NAME

Class::ReluctantORM::SQL::OrderBy - Represent an ORDER BY clause in a SQL statement

SYNOPSIS

  my $ob = Class::ReluctantORM::SQL::OrderBy->new();
  $ob->add($col);
  $ob->add($col, 'DESC');
  @cols = $ob->columns();

METHODS

new()

Constructor. No arguments.

@cols = $ob->columns();

Lists the Class::ReluctantORM::SQL::Columns in the order by clause, in order of occurence. No sort direction is provided.

@tables = $ob->tables();

Returns a list of (non-unique) tables referenced in the clause.

@col_pairs = $ob->columns_with_directions();

Returns an array of two-element arrays. In each subarry, the first element is the Class::ReluctantORM::SQL::Column, and the second is the sort direction (either 'ASC' or 'DESC').

$ob->add($col);

$ob->add($col, $direction);

Adds a sort criteria to the clause. $col is a Class::ReluctantORM::SQL::Column. $direction is either of the strings 'ASC' or 'DESC', default 'ASC'.

$str = $ob->pretty_print();

Outputs the clause as a human-readable, driver-neutral string. Useless for SQL execution.

$clone = $ob->clone();

Deeply clones each sort expression, and copies each direction.