# OPTIONS

### Options

Options are the way to store extension-related settings that have an impact on a company. All the data is stored in the options table and mapped with the company\_id. Here is the columns options table has.

### Structure of the miniCal options Table

The options table has a similar structure to the metadata tables. It has five fields:

* `option_ID`
* `company_id`- Current company id.
* `option_name`- Name of an option (key).
* `option_value`- Value of option (value).
* `autoload` - Whether to load the option when extension starts up. Default is enabled. The boolean value `true/false.`

Each record in the `option_name` field will be a unique value: if you add more than one value to an option, miniCal stores this in an array in the `option_value` field.

```php
// Add a new option.
add_option(string $option, $value = '', bool $autoload = true)

// Removes option by name.
delete_option( string $option )

// Retrieves an option value based on an option name.
get_option( string $option, bool $default = false)

// Update the value of an option that was already added.
update_option( string $option, $value = '', bool $autoload = true )
```

### Using the Options

The Options consists of four functions that allow you to add, get, update or delete options:

<table><thead><tr><th width="215">Method</th><th>Description</th><th>Parameters Description</th><th>Return value</th></tr></thead><tbody><tr><td><code>add_option()</code></td><td>Adds a new option value.</td><td><strong><code>add_option(string $option, $value = '', bool $autoload = true)</code></strong><br><br><strong>1.</strong> string $option (Required) Name of the option to add.<br><strong>2.</strong> mixed $value (Optional) Option value.<br><strong>3.</strong> bool $autoload (Optional) Whether to load the option when extension starts up. Default is enabled.<br></td><td><strong>bool</strong><br>True if the option was added, null otherwise.</td></tr><tr><td><code>get_option()</code></td><td>Get option value.</td><td><strong><code>get_option( string $option, bool $default = false)</code></strong><br><br><strong>1.</strong> string $option (Required) Name of the option to add.<br><strong>2.</strong> bool $default (Optional) Default value to return if the option does not exist.<br></td><td><strong>bool</strong><br>Value of the option. A value of any type may be returned, If there is no option in the database, boolean false is returned</td></tr><tr><td><code>update_option()</code></td><td>Update option value.</td><td><strong><code>update_option( string $option, $value = '', bool $autoload = true )</code></strong><br><br><strong>1.</strong> string $option (Required) Name of the option to update.<br><strong>2.</strong> mixed $value (Required) Option value.<br><strong>3.</strong> bool $autoload (Optional) Whether to load the option when extension starts up. Default is enabled.<br></td><td><strong>bool</strong><br>True if the value was updated, false otherwise.</td></tr><tr><td><code>delete_option()</code></td><td>delete option value.</td><td><strong><code>delete_option( string $option )</code></strong><br><br><strong>1.</strong> string $option (Required) Name of the option to delete.</td><td><strong>bool</strong><br>True if the option was deleted, false otherwise.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.minical.io/build-an-extension/store-custom-data/options.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
