NAME

Mojo::Hakkefuin::Backend::mariadb - MariaDB/MySQL Backend.

SYNOPSIS

use Mojo::Hakkefuin::Backend::mariadb;

my $mariadb = Mojo::Hakkefuin::Backend::mariadb->new(
  dir => 'path/your/dir/migrations',
  dsn => 'mariadb://username:password@hostname/database'
);

# use as a method
my $backend = $backend->dsn;
$backend->dsn('mariadb://username:password@hostname:port/database');

# or
$backend->dsn('mysql://username:password@hostname:port/database');

DESCRIPTION

Mojo::Hakkefuin::Backend::mariadb is a backend for Mojolicious::Plugin::Hakkefuin based on Mojo::Hakkefuin::Backend. All necessary tables will be created automatically.

ATTRIBUTES

Mojo::Hakkefuin::Backend::mariadb inherits all attributes from Mojo::Hakkefuin::Backend and implements the following new ones.

dsn

# Example use as a config
my $backend = Mojo::Hakkefuin::Backend::mariadb->new(
  ...
  dsn => 'mariadb://username:password@hostname:port/database',
  ...
);

# use as a method
my $backend = $backend->dsn;
$backend->dsn('mariadb://username:password@hostname:port/database');

# or
$backend->dsn('mysql://username:password@hostname:port/database');

This attribute for specify Data Source Name for DBMS MariaDB.

dir

# Example use as a config
my $backend = Mojo::Hakkefuin::Backend::mariadb->new(
  ...
  dir => '/path/location/of/dir/migrations/',
  ...
);

# use as a method
my $backend = $backend->dir;
$backend->dir('/path/location/of/dir/migrations/');

This attribute for specify path (directory address) of directory migrations configuration file.

METHODS

Mojo::Hakkefuin::Backend::mariadb inherits all methods from Mojo::Hakkefuin::Backend and implements the following new ones. In this module contains 2 section methods that is Table Interaction and Data Interaction.

Table Interaction

A section for all activities related to interaction data in a database table.

table_query

my $table_query = $backend->table_query;
$backend->table_query;

This method used by the create_table method to generate a query that will be used to create a database table.

check_table

$backend->check_table();
my $check_table = $backend->check_table;

This method is used to check whether a table in the DBMS exists or not

create_table

$backend->create_table();
my $create_table = $backend->create_table;

This method is used to create database table.

empty_table

$backend->empty_table;
my $empty_table = $backend->empty_table;

This method is used to delete all database table (It means to delete all data in a table).

drop_table

$backend->drop_table;
my $drop_table = $backend->drop_table;

This method is used to drop database table (It means to delete all data in a table and its contents).

Data Interaction

A section for all activities related to data interaction in a database table. These options are currently available:

$id

A variable containing a unique id that is generated when inserting data into a table.

$identify

The variables that contain important information for data login but not crucial information.

$cookie

The variable that contains the cookie hash, which hash is used in the HTTP header.

$csrf

The variable that contains the csrf token hash, which hash is used in the HTTP header.

$expires

The variable that contains timestamp format. e.g. 2023-03-23 12:01:53. For more information see Mojo::Hakkefuin::Utils.

create($identify, $cookie, $csrf, $expires)

$backend->create($identify, $cookie, $csrf, $expires)

Method for insert data login.

read($identify, $cookie)

$backend->read($identify, $cookie);

Method for read data login.

update()

$backend->update($id, $cookie, $csrf);

Method for update data login.

update_csrf()

$backend->update_csrf($id, $csrf);

Method for update CSRF token login.

update_cookie()

$backend->update_cookie($id, $cookie);

Method for update cookie login.

upd_coolock()

$backend->upd_coolock();

Method for update cookie lock session.

upd_lckstate()

$backend->upd_lckstate();

Method for update lock state condition.

delete($identify, $cookie)

$backend->delete($identify, $cookie);

Method for delete data login.

check($identify, $cookie)

$backend->check($identify, $cookie);

Method for check data login.

new()

use Mojo::Hakkefuin::Backend::mariadb;

my $backend = Mojo::Hakkefuin::Backend::mariadb->new(
  dir => 'path/your/dir/migrations',
  dsn => 'mariadb://username:password@hostname/database'
);

Construct a new Mojo::Hakkefuin::Backend::mariadb object.

SEE ALSO