<?php

use mirzaev\baza\database,
    mirzaev\baza\column,
    mirzaev\baza\record,
    mirzaev\baza\enumerations\encoding,
    mirzaev\baza\enumerations\type;

// Initializing path constants
define('INDEX', __DIR__);
define('ROOT',  INDEX . DIRECTORY_SEPARATOR     . '..' . DIRECTORY_SEPARATOR    . '..' . DIRECTORY_SEPARATOR    . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');

// Initializing dependencies and system settings
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
require SETTINGS . DIRECTORY_SEPARATOR . 'system.php';

// Initializing a path to the Baza database binary file
$file = DATABASES . DIRECTORY_SEPARATOR . 'telegram.baza';

// Instanciating new database class we want to read
$database = new database()
    ->encoding(encoding::utf8)
    ->columns(
        new column('identifier', type::long_long_unsigned),
        new column('domain', type::string, ['length' => 32]),
        new column('name_first', type::string, ['length' => 64]),
        new column('name_second', type::string, ['length' => 64]),
        new column('language', type::string, ['length' => 2]),
        new column('robot', type::char),
        new column('updated', type::integer),
        new column('created', type::integer)
    )
    ->connect($file);

// Reading the whole database array
$read = $database->read();
print_r($read);
