Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

$objs = DataObject::get('Group_Members'); doesn't work!


Go to End


2 Posts   1912 Views

Avatar
NtM

Community Member, 39 Posts

13 January 2010 at 12:07pm

I'm trying to make a request to the table Group_Members.
I get an error "[User Error] Bad class to singleton() - Group_Members"

Line 261 in /var/www/***/subdomains/test2/httpdocs/sapphire/core/Core.php
Source

252 *
253 * @param string $className
254 * @return Object
255 */
256 function singleton($className) {
257 global $_SINGLETONS;
258 if(!isset($className)) user_error("singleton() Called without a class", E_USER_ERROR);
259 if(!is_string($className)) user_error("singleton() passed bad class_name: " . var_export($className,true), E_USER_ERROR);
260 if(!isset($_SINGLETONS[$className])) {
261 if(!class_exists($className)) user_error("Bad class to singleton() - $className", E_USER_ERROR);
262 $_SINGLETONS[$className] = Object::strong_create($className,null, true);
263 if(!$_SINGLETONS[$className]) user_error("singleton() Unknown class '$className'", E_USER_ERROR);
264 }
265 return $_SINGLETONS[$className];
266 }

There is no ClassName field in the table. How to make a request?

Avatar
Willr

Forum Moderator, 5523 Posts

14 January 2010 at 12:49pm

Because Group_Members isn't a dataobject. That table is a relationship table made up of groups -> member relationships.

If you want to get all the groups which have a member you can call Groups() on a member object, and if you want all the members in a group you can call Members() on a group object.