1

In my Cakephp application I have define HABTM relation between User Table ( /app/Model/User.php) and Group Table (/app/Model/Group.php ) on 'username'(of User Table) and 'group_id'(of Group Table).

And the relation table is user_groups ( /app/Model/UserGroup.php).

In my application I want to add one raw in UserGroup containing group_id="something" and username=NULL.

As per HABTM defination it's not allow to add raw contain null 'username'. But in CakePHP Documentation there is option for custom insertQuery.

SO how to write this custom insertQuery for some special condition ?

1 Answer 1

0

In cakephp you cannote modify the table of join of an HABTM relationship. If you want a custom join table you have to create manually inside the database it, create its model and in UeserModel use an hasMany relation with UserGroup and the same thing inside the table Group.

This is how to customize a join table in a HABTM relationship in cakephp.

1
  • But having HABTM cakephp not allowing to insert null value for foreignKey. And I want to do that. Commented Jul 13, 2013 at 12:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.