We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

reusable does not work

items (id, node_id, user_id, etc...)

    $this->belongsTo('node_id', 'Nodes', 'id', array(
        'reusable' => true
    ));

    $this->belongsTo('user_id', 'Users', 'id', array(
        'reusable' => true
    ));

template foreach $items

    echo $item->users->username; // work
    echo $item->nodes->name; // duplicate queries

Why for Nodes reusable dont work?

I don't quite understand, what's your problem here ? Obviously to first time display it he needs to execute query. On next accessing there will be no query.



1.5k
edited Oct '16

in foreach one user and many nodes. reusable work on duplicate fields? query is run for each Node. how to select all relations in one request? only use QueryBuilder?

edited Oct '16

Many nodes ? I don't see many nodes here. Relation is belongs_to. It will reuse only within model.

Like if user with id 1 and user with id 2 can have same node - it will not be reused between them i guess.