Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 827 Bytes

option-api.md

File metadata and controls

43 lines (28 loc) · 827 Bytes

The Options API is a simple and standardized way of storing data in the database. The Options API makes it easy to create, access, update, and delete those options. All the data is being stored in the options.table.xml under a given custom name.

Add new option

Option::add('pages_limit', 10);
Option::add(array('pages_count' => 10, 'pages_default' => 'home'));

Update option value

Option::update('pages_limit', 12);
Option::update(array('pages_count' => 10, 'pages_default' => 'home'));

Get option value

$pages_limit = Option::get('pages_limit');
if ($pages_limit == '10') {
    // do something...
}

Check if option exist

if (Option::exists('pages_limit')) {
    // do something...        
}

Delete option

Option::delete('pages_limit');