Thanks guys for answering.

I solved it but I can't find it how. I baked again the model,
controller, and view after a two days and it worked automagically. I
have checked the new model and and the SQL query and they are exactly
the same as before.
The only thing I can think of is a cache issue ?!!?

The join table doesn't need an id column according to the
documentation, but I tried that as well anyway. Now is working without
the id column.

Also checked the equipment plural thing, but equipment is a valid
plural for cake, it doesn't complain with other existing relations.

If I find what it was I will post it here :( Thanks again guys.

On Dec 21, 10:28 pm, websurfshop <[email protected]> wrote:
> Your table names should be plural to the Model name per Cake
> convention.  The 'Equipment' Model is on the "equipments" table in
> your database.  Bake has not way to find the table unless it is plural
> to the model name.
>
> On Dec 19, 9:32 am, Juan <[email protected]> wrote:
>
> > Any HABTM guru out there, please I need to be enlightned.
>
> > There are 3 tables and their models :
> > Equipment (id, name, ...)
> > Expenses (id, name, ...)
> > Equipment_Expenses (equipment_id, expense_id)
>
> > I want to establish a HABTM relation between equipment a expenses
> > (many expenses 'hanging' from a equipment)
>
> > this is my 'baked' Equipment model:
>
> >         var $hasAndBelongsToMany = array(
> >                         'Expense' => array('className' => 'Expense',
> >                                                 'joinTable' => 
> > 'equipment_expenses',
> >                                                 'foreignKey' => 
> > 'equipment_id',
> >                                                 'associationForeignKey' => 
> > 'expense_id',
> >                                                 'unique' => true,
> >                                                 'conditions' => '',
> >                                                 'fields' => '',
> >                                                 'order' => '',
> >                                                 'limit' => '',
> >                                                 'offset' => '',
> >                                                 'finderQuery' => '',
> >                                                 'deleteQuery' => '',
> >                                                 'insertQuery' => ''
> >                         )
> >         );
>
> > I also 'baked' the controller and standard views. When I see an
> > Equipment entry, the Expense array is empty despite the tables are
> > populated.
>
> > The SQL query that cakephp generates is:
>
> >         SELECT `Expense`.`id`, `Expense`.`expense_type_id`, 
> > `Expense`.`name`,
> > `Expense`.`desc`, `Expense`.`spent_on`, `Expense`.`ammount`,
> > `Expense`.`ammount_back`, `EquipmentExpense`.`equipment_id`,
> > `EquipmentExpense`.`expense_id` FROM `expenses` AS `Expense` JOIN
> > `equipment_expenses` AS `EquipmentExpense` ON
> > (`EquipmentExpense`.`equipment_id` = 1 AND
> > `EquipmentExpense`.`expense_id` = `Expense`.`id`) WHERE 1 = 1
>
> > Please note `EquipmentExpense`.`equipment_id` = 1 is the id for the
> > equipment entry I want to see
>
> > running this query in mysql also returns empty records.
>
> > The only similar post I found on the group was this one, tried
> > everything on that post but doesn't help
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/a6e7780e...
>
> > This is a very basic HABTM structure, why is not working?
> > Any help will be very much appreciated. Thanks
--~--~---------~--~----~------------~-------~--~----~
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