> Well Ben, Cars don't belong to Wheels,  Wheels belong to cars.
> Cars hasMany Wheels, and Wheels hasOne Tire.
> Your lookup is exactly reversed, I would start there.

Not so. Although "true" from an English grammar point of view, it
depends on the model structure.

If the `cars` table contains a `wheel_id` and the `wheels` table
contains a `tyre_id` then this is correct.

> PaginatorHelper lets you use standard find() options, including
> recursive. If I understand you correctly, setting it to 2 should work.

No, it won't - recursive=2 will retrieve the associated `Tyre` model,
but won't allow conditions on it because it won't be joined; it will
be retrieved in a separate query.

> Now i want to paginate the Cars und Filter by Wheels.type. But i can't
> beacause pagination didn't find the Wheels belongsTo (and so didn't
> join the Wheels table) at the moment of filtering.
>
> Is there a way to get it?

It IS possible. You have to create a synthetic relation where `Car`
belongsTo `Tyre` using the `Wheel.tyre_id` as a foreign key.

Cake doesn't allow this normally, but you can do it with
foreignKey=false and conditions:

$this->Car->bindModel(array(
  'belongsTo' => array(
          'WheelTyre' => array(
                  'className' => 'Wheel',
                        'foreignKey' => false,
                        'conditions' => 'WheelTyre.id=Wheel.tyre_id',
                        'fields'     => array()
                )
        )
), false
);

$conditions = array(
  'WheelTyre.type =' => 'something'
);

$cars = $this->paginate('Car', $conditions);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to