PEAR Manual
Prev |  | Next

# ->orderBy()

->orderBy() -- Add an order by condition

## Synopsis

``void $DB_DataObject->orderBy` ([string $order])`

## Description

Adds a order by condition. Calling this without any arguments clears the current order condition.

## Parameter

- `string $order` - Order

## Note

This function can not be called statically.

## Example

Example 33-1. Setting the order by
    <?php
    $person = new DataObjects_Person;
    $person->orderBy('name');
    $person->orderBy('age, eye');
    $person->find();

    // or with direction:
    $person = new DataObjects_Person;
    $person->orderBy('name ASC');
    $person->orderBy('age DESC, eye');
    $person->find();

    ?>

Example 33-2. Resulting SQL
    SELECT * FROM person ORDER BY name, age, eye

Prev | Home | Next
->limit() | Up | ->groupBy()