K
K
karenshahmuradyan2017-12-07 19:24:11
Zend Framework
karenshahmuradyan, 2017-12-07 19:24:11

Why doesn't order(user_full_name) work?

public function getAllInvoices($where, $offset, $limit, $orderColumn, $orderDirection)
    {
        $this->setEntity(new \Platform\Invoice\Entity\Backoffice\InvoiceTableRow());

        $select = new Select();
        $select->from($this->getTable());
        $select->columns([
            'id',
            'invoice_type',
            'status',
            'price',
            'price_original',
            'title',
            'creation_date' => 'created',
        ]);

        $select->join(
            DbTables::TBL_USERS,
            DbTables::TBL_USERS . '.id = ' . $this->getTable() . '.user_id',
            [
                'user_full_name' => new Expression("CONCAT(first_name,' ',last_name)"),
                'user_id' => 'id'
            ],
            Select::JOIN_LEFT
        );

        $select->where($where);
        $select->offset(intval($offset));
        $select->limit(intval($limit));

        $select->group($this->getTable() . '.id');
        $select->order([$this->getTable() . '.created' => Select::ORDER_DESCENDING])->
        order([$this->getTable() . '.invoice_type' => Select::ORDER_DESCENDING])->
        order([$this->getTable() . '.status' => Select::ORDER_DESCENDING])->
        order([$this->getTable() . '.user_full_name' => Select::ORDER_DESCENDING])->
        order([$this->getTable() . '.price' => Select::ORDER_DESCENDING]);
        $select->quantifier(new Expression('SQL_CALC_FOUND_ROWS'));

        $result = $this->executeSelect($select);

        return $result;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-12-07
@BorisKorobkov

order([$this->getTable() . '.user_full_name'...

There is no such field in the table.
Try just 'user_full_name' in order. Ornew Expression...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question