function UserpointsAPITestCase::getPoints in User Points 7
Same name and namespace in other branches
- 7.2 userpoints.test \UserpointsAPITestCase::getPoints()
Returns the user points.
Parameters
$uid: User uid for which the points should be selected.
$points: Optionaly define which transaction should be loaded by specifying the points.
$sum: If TRUE, calculate the sum of all matching transaction rows.
Return value
Amount of points according to the arguments.
4 calls to UserpointsAPITestCase::getPoints()
- UserpointsAPITestCase::testBasicCall in tests/userpoints_api.test 
- Call userpoints_userpointsapi() with just points.
- UserpointsAPITestCase::testExpiration in tests/userpoints_api.test 
- UserpointsAPITestCase::testModeration in tests/userpoints_api.test 
- UserpointsAPITestCase::testParamsArrayCall in tests/userpoints_api.test 
- Call the api functions with an array.
File
- tests/userpoints_api.test, line 156 
- Contains test classes for userpoints module.
Class
- UserpointsAPITestCase
- API Tests.
Code
function getPoints($uid, $points = NULL, $sum = FALSE) {
  $query = db_select('userpoints', 'p');
  if ($sum) {
    $query
      ->addExpression('SUM(points)');
  }
  else {
    $query
      ->addField('p', 'points');
  }
  $query
    ->condition('uid', $uid);
  if ($points) {
    $query
      ->condition('points', $points);
  }
  return (int) $query
    ->execute()
    ->fetchField();
}