HomePHP Page 4 - User Authentication With patUser (part 3)
Natural Selection - PHP
In this concluding article, find out about how to use patUser toidentify users and groups by different criteria, track a user's clicks, maintain user statistics, and gracefully handle errors.
You've already seen, in my examination of the getUsers() and getGroups() methods, that you can apply selection criteria (as the second argument to those methods) to return a result subset containing only the records you need. Here's an example:
The code snippet above would return a list of only those
users who were female.
There are three components to the second argument in the snippet above: the field, the value, and the selection criteria. The first two are fairly obvious: the "field" key specifies the field against which to match, while the "value" specifies the value against which records are to be compared. The critical element, though, is the third key, "match", which defines how the comparison between the "field" and the "value" will actually be performed.
patUser permits comparison using any of the following conditions:
"match" => "exact" field value equals "value" when compared in a case-sensitive manner
"match" => "greater" field value must be greater than "value"
"match" => "lower" field value must be lower than "value"
"match" => "greaterorequal" field value must be greater than or equal to "value"
"match" => "lowerorequal" field value must be lower than or equal to "value"
"match" => "contains" field value contains "value"
"match" => "like" field value equals "value" when compared in a case-insensitive manner
"match" => "startswith" field value starts with "value"
"match" => "endswith" field value starts with "value"
"match" => "between" field value is between the "value" array (x,y)
The following snippet would return the IDs of all users whose username contains an "e",