Jump to content


set_relation_n_n

set_relation_n_n

  • Please log in to reply
1 reply to this topic

#1 magicrivers

magicrivers

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 12 February 2013 - 04:39 AM

CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  `admin_user_id` int(10) unsigned NOT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `groups_admin_user_id_foreign` (`admin_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(32) NOT NULL,
  `email` varchar(64) NOT NULL,
  `password` varchar(32) NOT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `group_user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `users_id` int(10) unsigned NOT NULL,
  `groups_id` int(10) unsigned NOT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `group_user_users_id_foreign` (`users_id`),
  KEY `group_user_groups_id_foreign` (`groups_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

ALTER TABLE `groups`
  ADD CONSTRAINT `groups_admin_user_id_foreign` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`id`);

ALTER TABLE `group_user`
  ADD CONSTRAINT `group_user_groups_id_foreign` FOREIGN KEY (`groups_id`) REFERENCES `groups` (`id`),
  ADD CONSTRAINT `group_user_users_id_foreign` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`);

For some reason the code on the group management side:

 

$crud->set_relation_n_n('users','group_user','users','groups_id','users_id','username');

does not seem to produce any output.

 

Any suggestions?



#2 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 15 February 2013 - 10:40 PM

Try to rename your virtual field name, it seems to have a conflict with your table name.

$crud->set_relation_n_n('user_field','group_user','users','groups_id','users_id','username');


No-CMS homepage : http://www.getnocms.com
No-CMS forum : http://www.getnocms.com/forum
No-CMS Github page : https://github.com/g...diAsgard/No-CMS

 

Please don't mix up No-CMS and groceryCRUD issues.
(eg: user authentication etc is No-CMS specific issue and has nothing to do with groceryCRUD)

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users