*/ final class settings extends core implements record_interface { use record_trait; /** * File * * @var string $database Path to the database file */ protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'settings.baza'; /** * Database * * @var database $database The database */ public protected(set) database $database; /** * Constructor * * @method record|null $record The record * * @return void */ public function __construct(?record $record = null) { // Initializing the database $this->database = new database() ->encoding(encoding::utf8) ->columns( new column('identifier', type::long_long_unsigned), new column('account', type::long_long_unsigned), /* new column('', type::), */ new column('updated', type::integer_unsigned), new column('created', type::integer_unsigned) ) ->connect($this->file); // Initializing the record $record instanceof record and $this->record = $record; } /** * Write * * @param int $account The account identifier (0 for disable) * * @return int|false The record identifier, if created */ public function write( int $account = 0, ): int|false { $record = $this->database->record( $this->database->count() + 1, $account, svoboda::timestamp(), svoboda::timestamp() ); // Writing the record into the database $created = $this->database->write($record); // Exit (success) return $created ? $record->identifier : false; } }