public function inventory($newInventory = null, $save = true) { static $inventory = null; if ($newInventory) { if ($newInventory instanceof inventory) { $this->inventory_id = $newInventory->id; $inventory = $newInventory; } else { if (is_int($newInventory)) { $this->inventory_id = $newInventory; $inventory = inventory::load_one($newInventory); } } if ($save) { $this->save(); } return $inventory; } if (!$inventory) { $inventory = inventory::load_one($this->inventory_id); } return $inventory; }
public function inventory($type = inventory::TYPE_GENERAL) { static $inventories = array(); if (!isset($inventories[$type])) { $inventories[$type] = inventory::load_one(array('char_id' => $this->id, 'type' => $type)); } return $inventories[$type]; }