*/ final class distribution extends core { /** * File * * @var string $database Path to the database file */ protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'localizations' . DIRECTORY_SEPARATOR . 'distributions.baza'; /** * Database * * @var database $database The database */ public protected(set) database $database; /** * Constructor * * @return void */ public function __construct() { // Initializing the database $this->database = new database() ->encoding(encoding::utf8) ->columns( new column('identifier', type::integer_unsigned), new column('distribution', type::integer_unsigned), new column('language', type::string, ['length' => 2]), new column('name', type::string, ['length' => 32]), new column('created', type::integer_unsigned), new column('updated', type::integer_unsigned) ) ->connect($this->file); } /** * Create * * Creates the distribution localization record in the database * * @param int $distribution Identifier of the distribution * @param language $language Language * @param string $name Name * * @return int|false The record identifier, if created */ public function create(int $distribution, language $language, string $name): int|false { // Initializing the identifier $identifier = $this->database->count() + 1; // Initializing the record $record = $this->database->record( $identifier, $distribution, $language->name, $name, svoboda::timestamp(), svoboda::timestamp() ); // Creating the accound record in the database $created = $this->database->write($record); // Exit (success) return $created ? $identifier : false; } }