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.

Problem with Resultset + json_encode

Hi, I am beginner in Phalcon and i have a problem with model resultset, how i can force a return relations objects of my model without manual access of sub models? Example:

$myModel = Robots::findFirstById(10); $myModel->robotsParts->Parts->name; //I cannot do this;

If i return this model to json_encode i don't receive a $myModel->robotsParts->Parts without a above access of object! I can configure to ResultSet for return all sub relations in a simple json_encode(Robots::findFirstById(10)) ? How i can resolve this problem with a better way?


edited Feb '16


in my opinion


      $myModel = Robots::findFirst(10);

          foreach ($myModel->robotsParts as $value) {

                $arrayname  []= $value->parts->name;


robots model

public function initialize()
        $this->hasMany("id", "RobotsParts", "parts_id");

for Resultsets u can use find