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.

How to ignore the First item of the records result?

$robots = Robots::find();

It can get all the records, but sometimes I want to ignore the first record, How to

I can't do it by SQL limit 1, x, because sometimes the first record can't be ignored

I try to do with array_shift($robots), It says $robots is not an array

can Robots::find() return with array?

edited May '16

Try this

$collection = Robots::find(array(
    'limit' => array('number' => $from, 'offset' => $offset)
));

or use Pagination https://docs.phalconphp.com/en/latest/reference/pagination.html#adapters-usage

or use Criteria https://docs.phalconphp.com/en/latest/api/Phalcon%5Mvc%5Model%5Criteria.html



6.2k
edited May '16

Robots::find() can return as array

Robots::find->toArray();


9.3k

thanks! I think toArray() is a phalcon function that covert an exists object to array....

how to return an array result of the models of phalcon (like php mysql_fetch_array() with array result instead of mysql_fetch_object() with object result)

Robots::find() can return as array

```php

Robots::find->toArray();

```



9.3k

offset is a solution, thanks! and I'd like to treat it with array.

Try this

```php $collection = Robots::find(array( 'limit' => array('number' => $from, 'offset' => $offset) )); ```

or use Pagination https://docs.phalconphp.com/en/latest/reference/pagination.html#adapters-usage

or use Criteria https://docs.phalconphp.com/en/latest/api/Phalcon%5Mvc%5Model%5Criteria.html



6.2k
Accepted
answer

@xaero7

Here you will find how to return as array by default (by using hydration): https://docs.phalconphp.com/en/latest/reference/models.html#hydration-modes



9.3k

That's it! Thanks

@xaero7

Here you will find how to return as array by default (by using hydration): https://docs.phalconphp.com/en/latest/reference/models.html#hydration-modes