PHP Class UserMetaModel, vanilla

Inheritance: extends Gdn_Model
Datei anzeigen Open project: vanilla/vanilla Class Usage Examples

Protected Properties

Property Type Description
$MemoryCache Store in-memory copies of everything retrieved from and set to the DB.

Public Methods

Method Description
__construct ( ) Class constructor. Defines the related database table name.
getUserMeta ( $UserID, $Key = null, $Default = null ) : array Retrieves UserMeta information for a UserID / Key pair.
setUserMeta ( $UserID, $Key, $Value = null ) : void Sets UserMeta data to the UserMeta table.

Method Details

__construct() public method

Class constructor. Defines the related database table name.
public __construct ( )

getUserMeta() public method

This method takes a $UserID or array of $UserIDs, and a $Key. It converts the $Key to fully qualified format and then queries for the associated value(s). $Key can contain SQL wildcards, in which case multiple results can be returned. If $UserID is an array, the return value will be a multi dimensional array with the first axis containing UserIDs and the second containing fully qualified UserMetaKeys, associated with their values. If $UserID is a scalar, the return value will be a single dimensional array of $UserMetaKey => $Value pairs.
public getUserMeta ( $UserID, $Key = null, $Default = null ) : array
$UserID integer UserID or array of UserIDs
$Key string relative user meta key
$Default optional default return value if key is not found
return array results or $Default

setUserMeta() public method

This method takes a UserID, Key, and Value, and attempts to set $Key = $Value for $UserID. $Key can be an SQL wildcard, thereby allowing multiple variations of a $Key to be set. $UserID can be an array, thereby allowing multiple users' $Keys to be set to the same $Value. ++ Before any queries are run, $Key is converted to its fully qualified format (Plugin. prepended) ++ to prevent collisions in the meta table when multiple plugins have similar key names. If $Value == null, the matching row(s) are deleted instead of updated.
public setUserMeta ( $UserID, $Key, $Value = null ) : void
$UserID int UserID or array of UserIDs
$Key string relative user key
$Value mixed optional value to set, null to delete
return void

Property Details

$MemoryCache protected_oe static_oe property

Store in-memory copies of everything retrieved from and set to the DB.
protected static $MemoryCache