You are here

function user_relationships_count_relationships in User Relationships 5

Public API for counting relationships that match specified criteria

Parameters

$criteria: An associative array of attributes to search for. Keys in the array should match column names in the user_relationships table. However, as a convenience, you can also specify the following keys: 'typename': match the rtid of the type with the given name (no join) 'uid', 'uid1', 'uid2': match either the requester_id or the requestee_id Examples: ('uid'=>1, 'approved'=>0) matches the pending relationships user 1 has either sent or received ('uid1'=>10, 'uid2'=>20) matches all relationships between users 10 and 20

The values for keys uid, uid1, uid2, rid, requester_id, requestee_id and rtid can be either scalars or arrays. If the values are arrays, the function will match relationships where the indicated column matches any of the entries in the array. Examples: ('uid1'=>10, uid2=>array(1,2,3,4)) matches all relationships between user 10 and users 1, 2, 3 or 4. ('uid'=>10, rtid=>array(1,2)) matches the relationships user 10 has of type 1 or 2

For the dates (created_at and updated_at), the first character of the value should be an operator, i.e. '<', '=' or '>'. The remainder should be the value, which can be either a (numeric) Unix timestamp, or a string formatted to match MySQL's date/timestamp format. e.g. 'created_at' => '>2006-12-31 23:59:59' to find relationships added in 2007 or later

Return value

count of the relationships that match the criteria

1 call to user_relationships_count_relationships()
user_relationships_request_relationship in ./user_relationships_api.inc
Public API for creating a relationship.

File

./user_relationships_api.inc, line 298

Code

function user_relationships_count_relationships($criteria = array()) {
  return _user_relationships_select_relationships($criteria, TRUE);
}