Source for file datacontainer.class.php
Documentation is available at datacontainer.class.php
* Defines the class DataContainer which handles data in form of DataItems. Handles things such as adding new items, deleting items and returning the value of an item.
* @author Daniel Nordstrom <dnordstrom@mankindorganization.com>
* @link www.mrnordstrom.com
* Container of any number of data items.
* Initializes private item variable to an array.
* Adds item to container.
* @param string $k Key to add.
* @param string $v Value to associate with key.
* Gets value associated with specified key.
* @param string $k Key to request.
foreach ( $this->items as $item ) // Loop to find requested key.
// Compares key in loop to the requested one, returns value if equal.
return $item->GetValue ();
// If key was not found, -1 is returned.
* Edits the value associated with specified key.
* @param string $k Key of item to edit.
* @param string $value New value of item.
* @return bool True on success and false if key does not exist.
foreach ( $this->items as $item ) // Loop to find requested key.
// Compares key in loop to the requested one, returns value if equal.
$item->SetValue($value); // Set new value.
return 1; // And return true on success.
// If key was not found, 0 is returned.
* Removes item with the specified key.
* @param string $k Key to remove.
for($x = 0; $x < count($this->items); $x++ ) // Find out which one we should delete, try to match against specified key.
unset ($this->items[$x]); // Here it is, let's delete it and...
return 1; // ...return 1 on success.
// If key was not found, -1 is returned.
|