Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Relation work but re-called anyway
  • Hi guys,

    Small issue in ORM relations (1.8) - I have this :

     $data['u'] = Model_Users_Collaborator::query()
    ->where($where)
    ->related(['schedule'])
    ->get_one();

    When I dump the obect, I see the schedule relation, no problem. But in the profiler I see another query under the main one : 

    SELECT `t0`.`id` AS `t0_c0`, `t0`.`collaborator_id` AS `t0_c1`, `t0`.`start` AS `t0_c2`, `t0`.`end` AS `t0_c3`, `t0`.`created_at` AS `t0_c4`, `t0`.`updated_at` AS `t0_c5` FROM `users_collaborators_schedules` AS `t0` WHERE `t0`.`collaborator_id` = '114'

    Like if the relation wasn't called in the query, same as lazy load mechanism.

    Thanks,
  • Harro VertonHarro Verton
    Accepted Answer
    I wouldn't know why that would happen with that specific query.

    Was that collaborator record already fetched and loaded from cache perhaps, which the cached version not having the relation loaded?

    Can you test it in case where you are absolutely sure it is the only query that runs? And when done, can you run that test again, but than against 1.9/develop of the ORM package?
  • Ah yes you are right, I changed this not so long ago.

    So how this cache work please ? And how would you empty it ?
  • Harro VertonHarro Verton
    Accepted Answer
    You can use

    ->from_cache(false)->

    to disable caching on a per-query basis. In 1.9/develop, you can disable the cache completely, using config, and use

    ->from_cache(true)->

    to explicitly cache the query.

    In general, it is worth while to think about how you query, since caching (and retrieving objects from cache) is a huge timesaver and a boost to the performance of your apps.
  • Ok thanks, I see.


Howdy, Stranger!

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

In this Discussion