We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13481
    • 97 Posts
    How do I get distinct values in a column using getCollection? Here is what I’m trying:

    $criteria = $xpdo->newQuery('Object');
        $criteria->select('DISTINCT name');
    $objects = $xpdo->getCollection('Object',$criteria);


    This returns an error:

    Fatal error: Maximum function nesting level of '100' reached, aborting!


    Am I doing something wrong or is this a bug?

    Thanks,

    James

      • 28215
      • 4,149 Posts
      Make sure you at least select the PK of the object.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 13481
        • 97 Posts
        Well, I just figured out I can just use groupby() to get the same results.

        $criteria = $xpdo->newQuery('Object');
        $criteria->groupby('name');
        $objects = $xpdo->getCollection('Object',$criteria);


        This works so my problem is solved.