Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Many To Many relationship with same nested Many To Many relationship
  • My first topic is immediately a question, so I first want to say how awesome this framework is. I have created a Post Model and a Tag Model with ORM. A Post can have many Tags and vice versa, so they have a many to many relationship. I would like to find all posts having a specific tag. But I want to also fetch all tags for each post in the same database call, so I thought of this; $query = Model_Tag::query();
    // Find the tag by slug
    $query->where('slug', '=', $slug);
    // Get the related posts for this tag and order them by creation date.
    $query->related('posts');
    $query->order_by('posts.created_at', 'desc');
    // Fetch the tags for each post
    $query->related('posts.tags')); But this seems to be wrong, nothing is returned at all (seems to get in some sort infinite loop).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!