Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:52:13+00:00 2026-06-17T19:52:13+00:00

I have a many to many relationship in FuelPHP as seen below: protected static

  • 0

I have a many to many relationship in FuelPHP as seen below:

    protected static $_many_many = array(
    'members' => array(
        'key_from' => 'team_id',
        'key_through_from' => 'team_id', 
        'table_through' => 'user_has_team', 
        'key_through_to' => 'user_id',
        'model_to' => 'Model_User',
        'key_to' => 'id',
    )
);

But I wanted to know if you can have a where clause in the relationship. For example:

    protected static $_many_many = array(
    'members' => array(
        'key_from' => 'team_id',
        'key_through_from' => 'team_id', 
        'table_through' => 'user_has_team', 
        'key_through_to' => 'user_id',
        'model_to' => 'Model_User',
        'key_to' => 'id',
        'where' => array('account_status' => 'active')
    )
);

So it only returns Model_User objects which have their account_status set to ‘active’. I know this is pushing it a bit but Fuel is awesome in lots of other was so I though there might be a way to do this.

Obviously you could do this with a query but I wanted to know if there is a way to do it using $_many_many

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:52:14+00:00Added an answer on June 17, 2026 at 7:52 pm

    Bit late to the party, but for people hitting this one on a search:

    You can define conditions on a relationship definition. At the moment ‘where’ and ‘order_by’ clauses are supported.

    This conditions are permanent, you can’t switch them on or off. So if you need both full and filtered access to a related model, you will have to define two relations.

    See http://fuelphp.com/docs/packages/orm/relations/intro.html#usage_rel_conditions for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many-to-many relationship between Game and Account models like below: class Account <
I have many to many relationship in entity framework. See image... I want to
I have a many-to-many relationship with a weight factor column in the bridge table
I have a many-to-many relationship in my django application where I use the add
I have a many-to-many relationship like this: A user has_many organizations through affiliations and
I have a many-to-many relationship between two tables, let's say Friends and Foods. If
I have a many-to-many relationship with a link box, and I want to pull
I have a many-to-many relationship between users and groups and I have a table
I have a many to many relationship: Product has many Categories and Category has
I have a many-to-many relationship between User s and Task s. I want the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.