NAME
SQL::Builder::OrderBy - An object representation of the ORDER BY clause
SYNPOSIS
my $orderby = SQL::Builder::OrderBy->new;
$orderby->list_push("foo ASC");
$orderby->list_push("bar");
$orderby->list_push("baz DESC");
# ORDER BY foo ASC, bar, baz DESC
print $orderby->sql;
my $expr = SQL::Builder::Order->new(
expr => "col1",
order => "DESC"
);
$orderby->list_push($expr);
# ORDER BY foo ASC, bar, baz DESC, col1 DESC
print $orderby->sql;
$orderby->asc("col2");
# ORDER BY foo ASC, bar, baz DESC, col1 DESC, col2 ASC
print $orderby->sql;
$orderby->desc("col3");
# ORDER BY foo ASC, bar, baz DESC, col1 DESC, col2 ASC, col3 DESC
print $orderby->sql;
DESCRIPTION
This class inherits from SQL::Builder::List
METHODS
init()
Calls init() on the parent class and turns off parenthesis on the list
asc(@args)
If a single argument is passed and it is a SQL::Builder::Order object, it is immediately added to the current object ($self->list_push($obj)) and the current object ($self) is returned. Any other pattern of arguments is passed to the constructor of a SQL::Builder::Order object. This object is added to the list (list_push()) and is returned. After the object is created, asc() is called on it
desc(@args)
This method works just like asc(), except after the object is created, desc() is called on it
_add_item($order[, @args])
This is a private method used by asc() and desc(). It is described in asc(), the only difference is that it accepts the sort order as the first argument. eg,
_add_item("DESC", expr => "col1")
SEE ALSO
SQL::Builder::List(3) SQL::Builder::Order(3) SQL::Builder(3)