new_with_id = true; $currency->id = $attributes['id']; unset($attributes['id']); } foreach ($attributes as $attribute => $value) { $currency->$attribute = $value; } $currency->save(); self::$createdCurrencies[] = $currency; return $currency; } public static function removeAllCreatedCurrencies() { $ids = self::getCreatedCurrencyIds(); $GLOBALS['db']->query('DELETE FROM currencies WHERE id IN (\'' . implode("', '", $ids) . '\')'); } public static function getCreatedCurrencyIds() { $ids = array(); foreach (self::$createdCurrencies as $currency) { $ids[] = $currency->id; } return $ids; } }