Here is a session based RAM.
<?
/**
* @Class: CContainerManager.class.php
* @Author: Abhishek Kumar (c) 2008.
**/
class ContainerManager
{
function __construct()
{
session_start();
Get();
}
function Get()
{
global $Container;
$Container = array();
if (isset($_SESSION['RAM']))
{
$Container = unserialize($_SESSION['RAM']);
}
}
function Set()
{
$_SESSION['RAM'] = serialize($GLOBALS['Container']);
}
function Clean()
{
if (isset($_SESSION['RAM']))
{
unset($_SESSION['RAM']);
unset($GLOBALS['Container']);
}
}
function Add($Associate, $Value)
{
global $Container;
if (!isset($Container[$Associate]))
{
$Container[$Associate] = $Value;
return true;
}
else
{
return false;
}
}
function Modify($Associate, $Value)
{
global $Container;
if (isset($Container[$Associate]))
{
$Container[$Associate] = $Value;
return true;
}
else
{
return false;
}
}
function Delete($Associate)
{
global $Container;
if (isset($Container[$Associate]))
{
unset($Container[$Associate]);
return true;
}
else
{
return false;
}
}
}
/*
$V002O = new CContainerManager();
$V002O->Add('kid','hello');
$V002O->Add('kid1','hello1');
$V002O->Add('kid2','hello2');
//$V002O->Clean();
print_r($Container);
//$V002O->Sync();
*/
?>
Comments
Post a Comment