mysql - Retrieve related data-set on Phalcon -


i have 2 tables. wanted return not parent data "lists", including relationship "listtypes". how can that?

$d = self::find(); // works - missing relations, see expected result.

tables:

  1. lists
  2. list types

with following code relations.

// models/lists.php <?php use phalcon\mvc\model;  class lists extends model {     public function initialize() {         $this->hasone('type_id', 'listtypes', 'id');     }      public function getdata() {         $d = self::find();     } } ?>  // models/listtypes.php <?php use phalcon\mvc\model;  class listtypes extends model {     public function initialize() {         $this->belongsto('id', 'lists', 'type_id');     } } ?> 

current results:

array (     [0] => array         (             [id] => 1             [name] => airbus             [type_id] => 1         )     [1] => array         (             [id] => 2             [name] => bmw             [type_id] => 2         ) ) 

expected results: -- want

array (     [0] => array         (             [id] => 1             [name] => airbus             [type_id] => 1             [type_name] => airplane         )     [1] => array         (             [id] => 2             [name] => bmw             [type_id] => 2             [type_name] => car         ) ) 

you can use recursive function related models long set alias child relation inside every parent model. php / phalcon - automatically nesting objects


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -