Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Check a model that contain the relation
  • I have two model
    standard
    product


    if any query happened with ->related(array('standards','products'))  then i want to filter the response with some condition, i think possible at after_load observer//

    But how i check that the model include these relation joined.

    Help please
  • HarroHarro
    Accepted Answer
    Is this a permanent or an optional filter?

    If it is a permanent filter, you can define conditions on the relation definition, in the form of WHERE clauses. See http://fuelphp.com/docs/packages/orm/relations/intro.html under "Configuration options".

    If it is not, all you can do is dynamically add where clauses to the query.

    Using an observer doesn't really work, since the data will already have been loaded. If you then start changing the data, the ORM will see that as a change, and might delete objects in the database if you are not careful.

    Always filter using SQL, not afterwards.

Howdy, Stranger!

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

In this Discussion