#1660 - How to load M2M (many to many) relationship table columns data from beans
Hi
currently I retreiving user bean
and then loading security group relationship
I want to use securitygroups_users tables fields
How to get those relationship table fields from bean?
current code :
$userBean = BeanFactory::getBean ( 'Users' );
$users = $userBean->get_list ( "users.date_modified DESC", "users.date_modified < '" . $dateTimeOffset . "'", 0, 10 );
foreach ( $users ['list'] as $user ) {
// load user security group if any
$user->load_relationship ( $rel_name );
$userAirlineGroups = $user->$rel_name->getBeans ();
**/****************I need here data of table securitygroups_users**********************/
**}
10 years ago
I'm assuming that the $rel_name is "SecurityGroups". I gave this a good try by looking through Sugar's code, but unfortunately you can only get the securitygroups table. The securitygroups_users table just isn't accessible with Sugar's framework. So the only way to do this is to do a direct SQL query and pass the user ID and the group ID. Make sure to also check for deleted = 0.
10 years ago
I am using now as following :
10 years ago
Now I understand what you are trying to do. Nice work! This is great. I'm going to close this out for now, but feel free to follow up if needed.