1. Go to this page and download the library: Download tasoft/setting library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tasoft / setting example snippets
use TASoft\Setting\StaticSetting;
use TASoft\Util\PDO;
/** @var PDO $PDO */
$setup = new StaticSetting($PDO, 'TABLE_NAME');
echo $setup->getSetting('my-setting', /* default value */ 'not-available');
// Defining a setting, see below
$setup->setSetting('my-setting', /* value */ 13, /* multiple */ false, /* temporary */ false);
// Passing true to temporary will only update the value for the current request, while passing false writes the passed value into the database persistently.
// Removes the setting
$setup->removeSetting('my-setting', /* temporary */ false);
// Again passing false to temporary will remove the setting from the database as well.
use TASoft\Setting\AbstractSetting;
use TASoft\Util\PDO;
class MySetting extends AbstractSetting {
// Adjust the sql table field names
const RECORD_ID_KEY = 'customized_id';
const RECORD_NAME_KEY = 'customized_name';
const RECORD_CONTENT_KEY = 'customized_content';
const RECORD_MULTIPLE_KEY = 'customized_multiple';
protected function getTableName() : string{
return "MY_TABLE_NAME";
}
protected function getPDO() : PDO {
// Get PDO from anywhere
/** @var PDO $PDO */
return $PDO;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.