You are here

function UserpointsAPITestCase::getPoints in User Points 7.2

Same name and namespace in other branches
  1. 7 tests/userpoints_api.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.

1 call to UserpointsAPITestCase::getPoints()
UserpointsAPITestCase::testExpiration in ./userpoints.test

File

./userpoints.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();
}