phpDataMapper_Query::order PHP Method

order() public method

ORDER BY columns
public order ( array $fields = [] )
$fields array Array of field names to use for sorting
    public function order($fields = array())
    {
        $orderBy = array();
        $defaultSort = "ASC";
        if (is_array($fields)) {
            foreach ($fields as $field => $sort) {
                // Numeric index - field as array entry, not key/value pair
                if (is_numeric($field)) {
                    $field = $sort;
                    $sort = $defaultSort;
                }
                $this->order[$field] = strtoupper($sort);
            }
        } else {
            $this->order[$fields] = $defaultSort;
        }
        return $this;
    }