Hello, All!

I have a problem. There are some tables in my project. Ex: Users and
Orgs:

CREATE TABLE IF NOT EXISTS `rabota_users` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `surname` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `birthdate` date default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`,`surname`,`name`)
)

CREATE TABLE IF NOT EXISTS `rabota_orgs` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `exp_date` date default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`,`title`)
)

And HABTM relationship between them:

CREATE TABLE IF NOT EXISTS `rabota_orgs_users` (
  `id` int(11) NOT NULL auto_increment,
  `org_id` int(11),
  `user_id` int(11),
  `post` varchar(255) NOT NULL
  PRIMARY KEY  (`id`),
)

In my CakePHP application I create relation:

/models/org.php

        var $hasAndBelongsToMany = array(
                'User' => array (
                        'className' => 'User',
                        'joinTable' => 'orgs_users',
                        'foreignKey' => 'org_id',
                        'associatedForeignKey' => 'user_id'
                )
        );

How to delete a record from orgs_users table where, for example,
user_id = 1 and org_id = 2?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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