We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24041
    • 7 Posts
    Hello,

    So I’ve just been tearing my hair out for the last 3 hours trying to figure out why this code:

    $siblings = $modx->getCollection('modResource',array(
        'published' => 1,
        'deleted' => 0,
        'parent' => 4
    ));


    Is throwing this error in one place on my site but not in others.

    modx Cannot use object of type modResource_mysql as array


    Then I realised that if I pass a limit attribute of 99, it works fine.

    Am I doing something wrong here or is this the intended behaviour? If the latter, then I think there needs to be some better documentation for this (the only reason I figured it out was because I created a whole new set of resources to test it and realised it was crashing when I got to 6 child resources.) And also would a more elegant catch of the error be possible?

    Out of interest, why is it limited?

      • 33968
      • 863 Posts
      I’ve never experienced a limit for getCollection - want to post the rest of your code so we can see it in context?
        • 24041
        • 7 Posts
        Ok seems that’s not the source of the issue (it’s actually not working with or without setting a limit); no idea why it works with 5 or below for me, it must be something else somewhere in the site.

        Sorry for confusing, please disregard the above...

        EDIT: Have restarted this thread with clarification as to the actual problem http://modxcms.com/forums/index.php/topic,67302.0.html