Home arrow PHP arrow 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.

TABLE OF CONTENTS:
  1. User Authentication With patUser (part 3)
  2. Making Exceptions
  3. The History Channel
  4. Natural Selection
  5. No Distinguishing Marks
  6. Big Brother Is Watching
  7. Endgame
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 6
May 07, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
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:




<?php $list = $u->getUsers( array("uid", "username"), array( array("field" => "sex", "value" => "F", "match" => "exact") ) ); ?>
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",

<?php $list = $u->getUsers( array("uid"), array( array("field" => "username", "value" => "e", "match" => "contains") ) ); ?>
while this one would return usernames and email addresses of all those users who have logged in more than 11 times and are over 18 years old:

<?php $list = $u->getUsers( array("username", "email"), array( array("field" => "count_logins", "value" => "11", "match" => "greater"), array("field" => "age", "value" => "18", "match" => "greater") ) ); ?>


 
 
>>> More PHP Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: