Thanks Villas, Yes, there could be a bug related with Firebird.
I forgot to mention I am using MySQL. If anyone experience this again I would recommend use scaffolding to help track down the problem, and emptying the cache as well - I know, maybe I'm getting too paranoid about that. Also noticed that the order of the models in the array $uses at the controller matters. And in the name of the join table the tables has to be in alphabetical order. On Dec 22, 12:44 am, villas <[email protected]> wrote: > Hi Juan > > I did not succeed in making the HABTM work with the Firebird DB. I > notice that someone else experienced this with Firebird and opened a > ticket:https://trac.cakephp.org/ticket/5602 > > Personally I simply worked around the problem and do not use a join > table any more. However, this is not always possible for others. > > Rgds. > > On Dec 19, 5:32 pm, 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 -~----------~----~----~----~------~----~------~--~---
