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.

Using a Model's function on a queried Simple object


I have a model named User, and I cannot get any of its functions work whether I get the model from a query.

use Phalcon\Mvc\Model;

class User extends Model
    public $id;
    public $name;

    public function getSomeExtraData()
        return 'something';

Whether I use User::find(), I cannot execute the getSomeExtraData() function on any of the returned Simple objects.

edited Aug '15

Szasz :P

::find() returns a ResultSet (array).

foreach(Model::find() as $item) {

Also if you select some columns, it will always return Simple object(not actual object) beacause its not a full object.

Köszi ;)

Thank you for the fast answer! I was using the same method, and it turns out that it even worked, but I had a character encoding issue in a file...

Szasz :P

::find() returns a ResultSet (array).

```php foreach(Model::find() as $item) { $item->getSomeExtraData(); } ```