Hello all, i noticed that 'reusable' flag works fine for one-to-one and many-to-one relations, but does not for many-to-many ((. It looks like another sad point in many-to-many land, along with this https://forum.phalcon.io/discussion/2190/many-to-many-expected-behaviour#C8434
Let's imagine we have an obvious many-to-many relation between Posts and Tags:
// Posts
$this->hasManyToMany(
"id",
"PostsTags",
"postref", "tagref",
"Tags",
"id", ['reusable' => true]
);
// PostsTags
public function initialize()
{
$this->belongsTo("tagref", "Tags", "id", ['reusable' => true]);
$this->belongsTo("postref", "Posts", "id", ['reusable' => true]);
}
// Tags
$this->hasManyToMany(
"id",
"PostsTags",
"tagref", "postref",
"Posts",
"id", ['reusable' => true]
);
and this queries the database again and again:
$post->Tags; // 'reusable' does not work at all
Any ideas?