Search code examples
phpfuelphpfuelphp-orm

fuelphp : setting conditions for has_many orm


Trying to set conditions for has_many orm on fuelphp, but this is not working I'm just having all the related invitations back when I try to get only the ongoing ones, here is how the has_many look like, any suggestions ?

protected static $_has_many = array(
'pending_invitations' => array(
    'key_from' => 'id',
    'model_to' => 'Model_Invitation',
    'key_to' => 'queue_id',
    'cascade_save' => false,
    'cascade_delete' => false,
    'conditions' => array(
        'where' => array(
            array('visitor_connected_at', 'is', null),
            array('advisor_connected_at', 'is', null),
        ),
    ),
),
);

Solution

  • You will want to update your fuel install to the latest 1.8/develop as this issue was reported recently and fixed. There was a bug in the query builder that was causing the value null to be translated to an empty string when used in join queries.

    The issue was reported here: http://fuelphp.com/forums/discussion/13081/how-to-set-conditions-to-_has_many

    And fixed here: https://github.com/fuel/core/commit/f708cc36e55177fc411bfe1c884bc321a24a14bd