Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

group error[SOLVED]

When I try group

$user->getRequests(array('limit' => 3, 'order' => 'id DESC', 'group' => "country, resort, hotel"));

I got error

Phalcon\Mvc\Model\Exception: Scanning error before 'country, resort,...' when parsing: SELECT [Request\Entity\Request].* FROM [Request\Entity\Request] WHERE [customer_id] = ?0 GROUP BY [country, resort, hotel] ORDER BY id DESC LIMIT 3 (147)

Backtrace

#0  Phalcon\Mvc\Model\Query->parse()
#1  Phalcon\Mvc\Model\Query->execute(Array([0] => 8), null)
#2  Phalcon\Mvc\Model->find(Array([0] => [customer_id] = ?0, [bind] => Array([0] => 8), [di] => Object(Phalcon\DI\FactoryDefault), [limit] => 3, [order] => id DESC, [group] => country, resort, hotel))
#3  Phalcon\Mvc\Model\Manager->getRelationRecords(Object(Phalcon\Mvc\Model\Relation), null, Object(User\Entity\User: 23), Array([limit] => 3, [order] => id DESC, [group] => country, resort, hotel))
#4  Phalcon\Mvc\Model->_getRelatedRecords(User\Entity\User, getRequests, Array([0] => Array([limit] => 3, [order] => id DESC, [group] => country, resort, hotel)))
#5  Phalcon\Mvc\Model->__call(getRequests, Array([0] => Array([limit] => 3, [order] => id DESC, [group] => country, resort, hotel)))

But when

$user->getRequests(array('limit' => 3, 'order' => 'id DESC', 'group' => "country"));
//or
$user->getRequests(array('limit' => 3, 'order' => 'id DESC', 'group' => "resort"));

it works correctly.

In docs, I find “group” => “name, status”, but for me its not work.

@xAockd

Not sure but try to write it exactly as the doc does (without spaces after comas)



8.0k

@SneakyBobito

still not working



83.0k
Accepted
answer

Can you try?

->getRequests(array('limit' => 3, 'order' => 'id DESC', 'group' => array("country", "resort", "hotel")));