Jump to content

OR-group in selector ?


celfred
 Share

Recommended Posts

Hello,

I'm facing a weird behavior (to me)... Why are these requests not returning the same values ?

 
// Test 01 : not working > returns empty
$allPlayers = $pages->find("team=$team"); // Returns the 10 players (1 of them has HP=14, others have HP>15, no players have coma=1)
$dangerPlayers = $allPlayers->find("(HP<=15), (coma=1)")->sort("coma, HP"); // Returns nothing ???
// Test 02 : Working as expected
$dangerPlayers = $pages->find("parent.name=players, team=$team, (HP<=15), (coma=1)")->sort("coma, HP"); // Returns the low HP player

If you can explain this to me, I would appreciate because this is causing me a headache right now ? 

Thanks !

Link to comment
Share on other sites

OR-groups are a feature of PageFinder selectors - selectors that query the database, e.g. $pages->find(), $page->find(), $page->children().

WireArray::find() is a completely different kettle of fish and doesn't support OR-groups.

Related:

@ryan, it would be good if the distinction between WireArray/PageFinder selectors were covered somewhere in the official documentation.

  • Like 7
Link to comment
Share on other sites

Well that's a great answer ! Thanks a lot @Robin S I was completely unaware of the distinction and your explanation is perfect. I had to struggle with similar issues before and that's quite a step forward for me. Thanks !

I'm gonna take some time to think about all this and read over my code.

  • Like 1
Link to comment
Share on other sites

14 hours ago, Robin S said:

it would be good if the distinction between WireArray/PageFinder selectors were covered somewhere in the official documentation

It is scattered all around the forum, for example:

It just needs to be compiled I guess.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...