Hi everybody,

I started using cakephp yesterday and I find it very "smart".

I have a problem trying to filter the results of a table used in a
model.

I have 2 tables, segments and parameters.

Parameters is defined as the following:
id
name
type_id

Segments id defined as the following:
id
name
par1_id
par2_id
par3_id

par1, par2 and par3 should be aliases of the parameters table filtered
by parameters.type_id.
E.g.
parameters:
1   Toyota   55   (55 is the type and means cars)
2   Banana  34  (34 means fruits)
3   hammer 23   (23 means tools)

When adding a new segment record par1 should list only cars, par2 only
fruits and par3 only tools.

I created a model for segment with a belongsTo variable:

        var $belongsTo = array(
                'Car' => array(
                        'className' => 'Parameter',
                        'foreignKey' => 'par1_id',
                        'conditions' => array('Car.type_id' => 55)
                ),
                'Fruit' => array(
                        'className' => 'Parameter',
                        'foreignKey' => 'par2_id',
                        'conditions' => array('Fruit.type_id' => 34)
                ),
                'Tool' => array(
                        'className' => 'Parameter',
                        'foreignKey' => 'par3_id',
                        'conditions' => array('Tool.type_id' => 23)
                ));

but the fields are not filtered.

In the query list section there are the 3 queries but there's no where
condition (something like .. INNER JOIN Parameters as Car WHERE
car.type_id=55) and no joins or aliases.
If I list segments In the query list section there are joins and
alaises yet. :-(

I don't understand if I'm missing something or doing something wrong
or I'm asking too much to cakephp.

Thank you for any suggestion

    maxx

--~--~---------~--~----~------------~-------~--~----~
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