LiveUser

PEAR::LiveUser authentication and permission framework

AdvancedSearch | AreaMap ]

Search:

  Welcome to LiveUser   Documentation   RoadMap   Wishlist   About  
  Documentation   FAQ   References   Tutorials   Other  

Username:

Password:


Areas In
This Wiki

BEPHPUG

Conferences

emPHPower

LiveUser

Main

MDB2

PDO

PEARThinkTank

PHPSVN

PHPTODO

RDBMS

WebBuilder2



Example


<?php
$LUA->perm->getGroups(
array(
'fields' => 'group_id',
'filters' => array('right_id' => array(1, 5)),
'select' => 'col',
'orders' => array('perm_user_id' => 'DESC'),
)
);
/* generates sql and gets the first column
SELECT lu_groups.group_id AS group_id
FROM lu_groups, lu_groupusers, lu_grouprights
WHERE lu_grouprights.right_id IN (1, 5)
AND lu_groups.group_id
= lu_grouprights.group_id
ORDER BY lu_groupusers.perm_user_id DESC */
?>

Example 2


<?php
/* first search for users by handle then get user fields and 
group names for the user in one list */
$users = $luadmin->auth->getUsers(array ( 
        'fields' => array ( 'auth_user_id', 'handle', 'email' ),
        'filters' => array (
            'handle' => array ('value' => $request.'%', 'op' => ' like ')
                    ),
            'rekey' => true 
                                        )
                                  );
var_dump($users);                        
if ($users === false) {
    echo '<strong>Error on line: '.__LINE__.'</strong><br />';
    print_r($luadmin->getErrors());
} elseif (empty ($users)) {
    echo 'No users were found.<br />';
} else {
    $user_ids = array_keys($users);
    $user_groups = $luadmin->perm->getUsers( array( 
                    'filters' => array('auth_user_id' => $user_ids),
                       'fields' => array('auth_user_id','group_id'),
                              'with' => array('group_id' => '' ),
                                        )
                                              );
      var_dump($user_groups);    
     // add the group names to $users list
     foreach ( $user_groups as $row ) {
        $group = current($row['groups'] );
        // only one group per user if you need more handle array here
        $users[ $row['auth_user_id'] ]['group_define_name'] = 
                                             $group['group_define_name'];
                   
     }
     // do something with list       
    self :: $template->set($users, 'choice_user.users');
}
?>

1) fields

(default: all fields from the first table in the "selectable_tables" property): this is an array containing the fields you want to fetch. the storage engine will attempt to automatically determine the most logical set of tables to join if necessary. this set of tables depends on the get*() method you called and can be affecred by the "selectable_tables" property. the order is relevant and therefore its not irrelevant which get*() method you call, even if the tables you are interested are listed in both "selectable_tables" arrays.

Example


<?php
 $params = array('fields' => array('foo', 'bar'));
?>

2) with

(default: no with): this setting uses "withFieldMethodMap?" property to determine what get*() method should be used for the given field. The specified field is implicitly added to the field list, if its not already listed there explicitly.

Example


<?php
 $params = array('with' => array('group_id'));
 $LUadmin->perm->getUsers($param);
?>

this will fetch all the users from the perm database and it will do a join with the groupusers table in order to fetch the group_id field. it will then do a getGroups() call using the group_id of each row as the only filter. the result will be stored into a key "groups".

3) 'filters'

(default: no filters): this is essentially a key value pair with the field on which the filter is to be executed is the key and the value is the criterion to match against. the simplest way is to have a simple scalar value which uses simple "=" comparisions. If you pass a php null value it will do an "IS NULL" check. if the value is a simple array that does not have a key "value" in any position an "IN ([comma separated list of values])" check will be made. if the value does contain a key "value", than it will also expect an "op" key which specifies the comparision operatator (like "=", "<", "NOT IN" etc.). If the value of the "value" key is an array it will create a comma separated list, if not it will just quote the value. multiple filters will be AND'ed.

fields specified inside the filters will affect what tables are joined.

4) 'orders'

(default: no order by): a simple array containing the names of fields by which the result should be ordered. fields specified inside the orders will affect what tables are joined.

5) 'select'

(default: 'all'): possible values are

  • 'all': if you want a two dimensional array containing all rows from the result set.
  • 'col': if you only want the first column of the result set as a single dimensional array
  • 'row': if you only want the first row of the result set as a single dimensional array
  • 'one': if you only want the first column of the first row of the result set as a scalar value

6) 'rekey'

(default: false): determines if the first dimension of the result where 'select' was set to 'all' should be the first column of each row.

7) 'group'

(default: false): determines if all of the values with the same value in the first column when using the rekey option should be grouped inside another array.

8) 'limit'

(default: none): determines if the number of rows in the result set should be limited by the given amount

9) 'offset'

(default: none): determines if the given number of rows should be skipped at the beginning of the result set

LiveUser:AdminFilters (87.123.110.14)
Fri, 18 Aug 2006, 21:43
[ Links | Source | History | RSS ]

This site powered by YaWiki 0.22 beta.

Tutorials
Quickstart
Complete
Observers
AdminFilters
Custom properties