Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » $objs = DataObject::get('Group_Members'); doesn't work!

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

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

Page: 1
Go to End
Author Topic: 1440 Views
  • NtM
    Avatar
    Community Member
    39 Posts

    $objs = DataObject::get('Group_Members'); doesn't work! Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: $objs = DataObject::get('Group_Members'); doesn't work! Link to this post

    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.

    1440 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.