Difference between a single array call vs multiple calls to exclude

This table should best summarise the difference - 1 = row is visible, 0 = row is excluded

| Name | SELECT * FROM Player WHERE (FirstName != 'A' OR LastName != 'B') | SELECT * FROM Player WHERE FirstName != 'A' AND LastName != 'B' |
| A B | 0 | 0 |
| A C | 1 | 0 |
This commit is contained in:
Matthew Hailwood 2017-10-03 16:18:37 +13:00 committed by Sam Minnée
parent b49d1d7fbd
commit b044fefc91
1 changed files with 9 additions and 0 deletions

View File

@ -401,6 +401,15 @@ Remove both Sam and Sig..
'FirstName' => 'Sam',
'Surname' => 'Minnée',
));
// SELECT * FROM Player WHERE (FirstName != 'Sam' OR LastName != 'Minnée')
Removing players with *either* the first name of Sam or the last name of Minnée requires multiple `->exclude` calls:
:::php
$players = Player::get()->exclude('FirstName', 'Sam')->exclude('Surname', 'Minnée');
// SELECT * FROM Player WHERE FirstName != 'Sam' AND LastName != 'Minnée'
And removing Sig and Sam with that are either age 17 or 43.