CWIS Developer Documentation
|
Persistent doubly-linked-list data structure, with its data stored in a specified database table. More...
Public Member Functions | |
__construct ($ItemTableName, $ItemIdFieldName, $SqlCondition=NULL, $ItemTypeFieldName=NULL) | |
Object constructor. More... | |
SqlCondition ($Condition=NULL) | |
Get or set/update SQL condition for referencing items in database. More... | |
InsertBefore ($TargetItemOrItemId, $NewItemOrItemId, $TargetItemType=NULL, $NewItemType=NULL) | |
Insert item into list before specified item. More... | |
InsertAfter ($TargetItemOrItemId, $NewItemOrItemId, $TargetItemType=NULL, $NewItemType=NULL) | |
Insert item into list after specified item. More... | |
Prepend ($ItemOrItemId, $ItemType=NULL) | |
Add item to beginning of list. More... | |
Append ($ItemOrItemId, $ItemType=NULL) | |
Add item to end of list. More... | |
GetIds () | |
Retrieve array of IDs of items in list, in the order that they appear in the list. More... | |
GetCount () | |
Get number of items in list. More... | |
Remove ($ItemId, $ItemType=NULL) | |
Remove item from list. More... | |
Public Attributes | |
const | UNINITIALIZED_ID = -1 |
const | LISTEND_ID = -2 |
Persistent doubly-linked-list data structure, with its data stored in a specified database table.
The specified table is usually also being used to store other information about the items being referenced by the list. Items in the list are assumed to have associated unique IDs, and anywhere item objects are passed in as parameters, the objects are assumed to have Id() methods that can be used to retrieve their associated IDs. More than one type of item can be included in a list, by use of the (optional) item type parameters. (Item IDs and types are assumed to be positive integers.)
Definition at line 21 of file PersistentDoublyLinkedList.php.
PersistentDoublyLinkedList::__construct | ( | $ItemTableName, | |
$ItemIdFieldName, | |||
$SqlCondition = NULL , |
|||
$ItemTypeFieldName = NULL |
|||
) |
Object constructor.
The specified database table must include an INT field containing IDs for the items being managed, and two other INT fields that have the same name with "Previous" and "Next" prepended to it (e.g. "ItemId", "PreviousItemId", and "NextItemId"). These additional INT fields should have a default value of -1. If mixed item types are to be included in the list, then the table must also include an INT field for the types of the items being managed, and two other INT fields that have the same name with "Previous" and "Next" prepended ("ItemType", "PreviousItemType", "NextItemType").
string | $ItemTableName | Database table in which to store list information. |
string | $ItemIdFieldName | Database field name for item IDs. |
string | $SqlCondition | SQL condition for referencing items in database. (OPTIONAL) This is intended to be used to specify a conditional clause to be added to any SQL statements that are used to store or retrieve information about items within the list, usually with the goal of information about multiple lists being stored in the same table in the database. The condition should not include a leading WHERE or other leading SQL clause joining operator. |
string | $ItemTypeFieldName | Database field name for item types. (OPTIONAL) |
Definition at line 47 of file PersistentDoublyLinkedList.php.
References SqlCondition().
PersistentDoublyLinkedList::Append | ( | $ItemOrItemId, | |
$ItemType = NULL |
|||
) |
Add item to end of list.
If the item is already present in the list, it is moved to the new location.
mixed | $ItemOrItemId | Item to add. |
int | $ItemType | Numerical type of item to add. (OPTIONAL) |
Definition at line 244 of file PersistentDoublyLinkedList.php.
References GetIds(), and Remove().
Referenced by InsertAfter().
PersistentDoublyLinkedList::GetCount | ( | ) |
Get number of items in list.
Definition at line 389 of file PersistentDoublyLinkedList.php.
References SqlCondition().
PersistentDoublyLinkedList::GetIds | ( | ) |
Retrieve array of IDs of items in list, in the order that they appear in the list.
Definition at line 289 of file PersistentDoublyLinkedList.php.
References SqlCondition().
Referenced by Append(), and Prepend().
PersistentDoublyLinkedList::InsertAfter | ( | $TargetItemOrItemId, | |
$NewItemOrItemId, | |||
$TargetItemType = NULL , |
|||
$NewItemType = NULL |
|||
) |
Insert item into list after specified item.
If the item is already present in the list, it is moved to the new location. If the target item is not found, the new item is added to the end of the list.
mixed | $TargetItemOrItemId | Item to insert after. |
mixed | $NewItemOrItemId | Item to insert. |
int | $TargetItemType | Type of item to insert after. (OPTIONAL) |
int | $NewItemType | Type of item to insert. (OPTIONAL) |
Definition at line 144 of file PersistentDoublyLinkedList.php.
PersistentDoublyLinkedList::InsertBefore | ( | $TargetItemOrItemId, | |
$NewItemOrItemId, | |||
$TargetItemType = NULL , |
|||
$NewItemType = NULL |
|||
) |
Insert item into list before specified item.
If the item is already present in the list, it is moved to the new location. If the target item is not found, the new item is added to the beginning of the list.
mixed | $TargetItemOrItemId | Item to insert before. |
mixed | $NewItemOrItemId | Item to insert. |
int | $TargetItemType | Type of item to insert before. (OPTIONAL) |
int | $NewItemType | Type of item to insert. (OPTIONAL) |
Definition at line 86 of file PersistentDoublyLinkedList.php.
PersistentDoublyLinkedList::Prepend | ( | $ItemOrItemId, | |
$ItemType = NULL |
|||
) |
Add item to beginning of list.
If the item is already present in the list, it is moved to the new location.
mixed | $ItemOrItemId | Item to add. |
int | $ItemType | Numerical type of item to add. (OPTIONAL) |
Definition at line 200 of file PersistentDoublyLinkedList.php.
References GetIds(), and Remove().
Referenced by InsertBefore().
PersistentDoublyLinkedList::Remove | ( | $ItemId, | |
$ItemType = NULL |
|||
) |
Remove item from list.
If the item is not currently present in the list, then the call has no effect.
int | $ItemId | ID of item to be removed. |
int | $ItemType | Numerical type of item to be removed. |
Definition at line 404 of file PersistentDoublyLinkedList.php.
Referenced by Append(), InsertAfter(), InsertBefore(), and Prepend().
PersistentDoublyLinkedList::SqlCondition | ( | $Condition = NULL | ) |
Get or set/update SQL condition for referencing items in database.
This is intended to be used to specify a conditional clause to be added to any SQL statements that are used to store or retrieve information about items within the list, usually with the goal of information about multiple lists being stored in the same table in the database. The condition should not include a leading WHERE or other leading SQL clause joining operator.
string | $Condition | New SQL condition clause. (OPTIONAL) |
Definition at line 71 of file PersistentDoublyLinkedList.php.
Referenced by __construct(), GetCount(), and GetIds().
const PersistentDoublyLinkedList::LISTEND_ID = -2 |
Definition at line 465 of file PersistentDoublyLinkedList.php.
const PersistentDoublyLinkedList::UNINITIALIZED_ID = -1 |
Definition at line 464 of file PersistentDoublyLinkedList.php.