⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Self table relation



goFrendiAsgard

goFrendiAsgard
  • profile picture
  • Member

Posted 29 June 2012 - 02:48 AM

So I have a navigation table which has a relation to itself. The table represent a tree-like structure. parent_id is pointed to another navigation_id.

Here is my work-around and (possibly) a solution:
https://github.com/scoumbourdis/grocery-crud/issues/71

naufal

naufal
  • profile picture
  • Member

Posted 29 June 2012 - 06:45 AM

Nice :) ty.

Omkar Nisal

Omkar Nisal
  • profile picture
  • Member

Posted 27 July 2015 - 00:50 AM

I tried doing as per your suggestion @goFrendiAsgard  but didn't work.

 

 

instead of this :

$crud->set_relation('reportstouser_id','`org_users`','{first_name} {last_name}');

I had to fetch table array and use field type: dropdown to avoid self set_relation.

 

 


CREATE TABLE IF NOT EXISTS `org_users` (
  `id` int(11) NOT NULL,
  `photo` varchar(265) COLLATE utf8_unicode_ci NOT NULL,
  `first_name` varchar(55) COLLATE utf8_unicode_ci NOT NULL,
  `middlename` varchar(35) COLLATE utf8_unicode_ci NOT NULL,
  `last_name` varchar(55) COLLATE utf8_unicode_ci NOT NULL,
  `comment` varchar(55) COLLATE utf8_unicode_ci DEFAULT NULL,
  `birthdate` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
  `mobile` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `role` varchar(55) COLLATE utf8_unicode_ci NOT NULL,
  `department_id` int(11) NOT NULL,
  `reportstouser_id` int(11) NOT NULL,
  `school_id` int(5) NOT NULL,
  `rights` varchar(7500) COLLATE utf8_unicode_ci NOT NULL,
  `email_address` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
  `postaladdress` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `joiningdate` varchar(12) COLLATE utf8_unicode_ci NOT NULL,
  `experience` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `notes` text COLLATE utf8_unicode_ci NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '0',
  `deleted` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;