The New Stuff


Oxwall MySQL Database (OWSQL101): How to Add, Retrieve or Delete Values in Oxwall Config Database


This tutorial (or course, if you like) will guide you on how to add, retrieve and manipulate data stored in Oxwall config SQL database.

Oxwall SQL

If you are asking the same question as the user above – picture taken from the Oxwall forum – I have done my best to put together a simple tutorial that will guide you on how to accomplish just that.

What you need?

Depending on how you want to use this tutorial, you may want to glance through the Oxwall plugin crash course and quickly download the Oxwall Plugin Skeleton. This two items will prepare you on how to structure your plugin (I’m assuming you are developing a plugin).

Finally, get your code editor ready and dive into the next paragraph.

Structure of Oxwall Config

The Oxwall config values are stored in a MySQL database table named ow_base_config. This table contains all the Oxwall key information such as your site name, current theme, site email, etc. This is also the table we will be storing our custom config values.

To avoid conflicts and duplicate config names, each configuration is stored with its plugin key.

Check if Config Exists

Before adding a config record to the table, you can check if the config already exists using the configExists('string','string') function. This function returns true if the config exist or false if it doesn’t exist.


if (!OW::getConfig()->configExists('plugin_key', 'field_name')) {
    //Configuration does not exist. Add new config or do something else

The above code makes sure that the config ‘field_name’ belonging to a plugin with the key ‘plugin_key’ does not exist on the Oxwall config MySQL database before adding a new config (or some action).

Adding a Config to Oxwall MySQL Database

Adding items to the database should be performed on plugin installation. This section should be done on yourplugin/install.php file.

if (!OW::getConfig()->configExists('plugin_key', 'field_name')) {//Make sure config does not exist
    OW::getConfig()->addConfig('plugin_key', 'field_name', 'default_value');//Add this config.

Collecting Values using Oxwall Form

This part of the coding should be done on the page where users are suppose to input config values (for the config you added earlier). The example will create a text input box. The content of the input box will be stored in ‘field_name’ in ow_base_config.

PHP (backend) code:

$form = new Form('form_name');//An instance of form named 'form_name'. Give your form a name

$foo = new TextField('field_name');//Create instance of TextField input for 'field_name'
$foo->setLabel('foo_name');//Set input label name
$foo->setHasInvitation(true);//Do you want to show placeholder?
$foo->setInvitation('foo_example');//Placeholder text
$foo->setDescription('foo_desc');//Input description

$fooSave = new Submit('save');
$fooSave->setValue('fooSave');//Submit button text


Save Form Values to Oxwall Config Database

if ( OW::getRequest()->isPost() && $form->isValid($_POST) ){//Check if form is submitted and valid
    $data = $form->getValues();
    //Save form values to field_name in db
    OW::getConfig()->saveConfig('plugin_key', 'field_name', trim($data['field_name']));
    //Display some fancy success message and redirect (optional)
    OW::getFeedback()->info('Some success msg');

HTML (frontend) code:

{form name='form_name'}
    <table class='ow_table_1'>
        <tr class='ow_alt1'>
            <td class='ow_label'>{label name='field_name'}</td>
            <td class='ow_value'>{input name='field_name'}{error name='field_name'}</td>
            <td class='ow_desc'>{desc name='field_name'}</td>
    <div class="clearfix ow_submit ow_smallmargin">
        <div class="ow_right">
            {submit name='save' class='ow_button ow_ic_save'}

Pay specific attention to ‘form_name’ and ‘field_name’. field_name is the name of your database config and form_name, of course, is the name of your form (just give it any name).

Retrieve Config Value from MySQL database


$dbFoo = OW::getConfig()->getValue('plugin_key', 'field_name');

Modify Oxwall Config Values


OW::getConfig()->saveConfig('plugin_key', 'field_name','new_value');
The following two tabs change content below.

Ebenezer Obasi

Senior executive editor at EwtNet
A web developer, IT undergrad, terrible entrepreneur, internet freak and a man of a few other incongruous talents, Ebenezer has been writing on technology since 2012, and plans to do so until a few days before his ultimate fate: cryogenic preservation. If resurrected, he is likely to go back to writing on technology.

Recieve Free Email Updates!

Subscribe to get new updates instantly delivered to your inbox. Select the specific category you want to recieve updates on and enter your email address below.

*A confirmation message will be sent to you, login to your e-mail account and click on the confirmation link to start enjoying this service.

Get the latest news on your Android mobile, Download our Android App

Recently Published


Awale, Backgammon and 1 other Game Technology has transformed

From time memorial, man has indulged himself into seeking ...

YouTube's demonetization aftermath

YouTube’s demonetization finally recognized; popular creators mad

YouTube (the behemoth video website and subsidiary of Google [GOOG]) ...


Why Pokemon GO Falls Short

Pokemon GO is a augmented reality mobile game that released (without ...

Playstation Plus

SONY announces increase in PS+ Pricing. How will this affect the service?

credit: Just when many PS+ members already felt let ...


Plan your Week Ahead: 7 Must Have Android Applications for the Week

Happy Sunday to all EWT readers! This is the 7th month of the ...

MTN Tariff Plans

MTN Tariff Plans – Latest Compilation of MTN Tariff Plans and Activation Code

Life with MTN can be a bit tricky. One day you get a notification to ...


Airtel Data Plans and Subscription Codes – Android, BlackBerry and Mega Data Bundle with SmartSPEEDOO

Compilation of the latest Airtel data plans for PC, Android, iOS, ...

MTN Tariff Plans

MTN Data Plans and Subscription Codes – Complete List with Text and USSD

Compilation of the latest MTN data plans for PC, Android, iOS, iPhone ...


Glo Data Plans and Subscription Codes – Full List for Monthly, Weekly, Daily & Campus Data Plans

Compilation of the latest Glo data plans for PC, Android, iOS, ...


Leave a Reply