# \AssocData

A class to manage associative data. Particularly useful for storing data for which there are up to 3 hierarchical keys in the database and retrieving that data at a later date. This class automatically serializes and de-serializes complex types such as arrays or objects.

## Summary

Methods
Properties
Constants
__construct()
Set()
Get()
GetFullNoCache()
GetList()
Delete()
find()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

File
  lib/class.AssocData.php
Package
  \CGExtensions
Class hierarchy
  \AssocData

## Tags

todo |

## Methods

### __construct()

    __construct(object $db, string $key1, integer $cachesize)

Constructor

#### Parameters

object | $db | A reference to the adodb db object
string | $key1 | The first key.
integer | $cachesize | int Number of elements to store in the cache

#

## Tags

todo |

### Set()

    Set(string $key2, mixed $value, string $key3, string $key4)

Store some data

`$obj = new AssocData(cmsms()->GetDb(),'addresses'); $obj->Set('user1','123 Somewhere Street');`

#### Parameters

string | $key2 | The second key
mixed | $value | The data to store
string | $key3 | An optional third key
string | $key4 | An optional fourth key

#

## Tags

todo |

### Get()

    Get(string $key2, string $key3, string $key4) : mixed

Retrieve stored data

will pull the data from the cache if possible, and if necessary from the database.

`$obj = new AssocData(cmsms()->GetDb(),'addresses'); $the_address = $obj->Get('user1');`

#### Parameters

string | $key2 | A second key
string | $key3 | An optional third key
string | $key4 | An optional 4th key

#### Returns

mixed —

The resulting data. If no data is found FALSE is returned.

#

## Tags

todo |

### GetFullNoCache()

    GetFullNoCache(string $key2, string $key3, string $key4) : mixed

Retrieve data from the database, ignoring any cache

#### Parameters

string | $key2 | A second key
string | $key3 | An optional third key
string | $key4 | An optional 4th key

#### Returns

mixed —

The resulting data. If no data is found FALSE is returned.

#

## Tags

todo |

### GetList()

    GetList(string $key2, string $key3) : array

List values stored in the cache for a particular set of keys

#### Parameters

string | $key2 |
string | $key3 | An optional third key

#### Returns

array —

listing all matching values.

#

## Tags

todo |

### Delete()

    Delete(string $key2, string $key3, string $key4) : bool

Delete a stored value.

`$obj = new AssocData(cmsms()->GetDb(),'addresses'); $obj->Delete('user1');`

#### Parameters

string | $key2 |
string | $key3 | an optional key3
string | $key4 | an optional key4

#### Returns

bool

#

## Tags

todo |

### find()

    find(mixed $key2, string $key3, string $key4) : array

Find all of the entries that match

#### Parameters

mixed | $key2 | (optional) (specify a string for an exact match, an array for IN expressin)
string | $key3 | (optional)
string | $key4 | (optional)

#### Returns

array —

of matching key1,key2,key3,key4 values

#

## Tags

todo |

### class.AssocData.php