public static function AddServer($DisplayName, $IP, $Port) { // Make it in the database Database::Insert(self::$TableName, array("Name" => $DisplayName, "IP" => $IP, "Port" => $Port)); // Flush the cache DB_Accessor::FlushMemCache("Servers"); }
public static function AddItemAction($ItemID, $ActionType, $ActionData, $Servers) { // Make it in the database Database::Insert(self::$TableName, array("ItemID" => $ItemID, "ActionType" => $ActionType, "ActionData" => $ActionData, "Servers" => $Servers)); // Flush the cache DB_Accessor::FlushMemCache("ItemAction"); }
public static function MakeCategory($CatName) { if (empty($CatName)) { return; } // Make it in the database Database::Insert(self::$TableName, array("Name" => $CatName)); // Flush the cache DB_Accessor::FlushMemCache("ItemCategory"); }
public function Delete() { $ItemActions = ItemAction::GetAllByField("ItemAction", "ItemID", $this->GetValue("ID")); // Delete all actions related to this item foreach ($ItemActions as $ItemAction) { // Delete all of the user actions using this Item Action $UserActions = UserAction::GetAllByField("UserAction", "ItemAction", $ItemAction->GetValue("ID")); foreach ($UserActions as $UserAction) { $UserAction->Delete(); } // Delete the actual item action $ItemAction->Delete(); } // Delete the saved image (we warned them) $this->DeleteImage(); // Literally delete the item itself Database::Query("DELETE FROM `%s` WHERE `ID` = %s;", static::$TableName, $this->Data["ID"]); DB_Accessor::FlushMemCache(get_class($this)); }
public static function GetByField($ClassName, $FieldName, $Value) { $ClassValues = get_class_vars($ClassName); if (isset(DB_Accessor::$DataCache[$ClassName])) { foreach (DB_Accessor::$DataCache[$ClassName] as $Obj) { if ($Obj->Data[$FieldName] == $Value) { return $Obj; } } } $Array = DB_Accessor::GetAllByField($ClassName, $FieldName, $Value); if (1 > count($Array)) { return new $ClassName(); } return array_pop($Array); }