Skip to content

Database

linchpin edited this page Feb 22, 2023 · 10 revisions

Database

Database base class

  • Full name: \CourierNotices\Core\Database
  • This class is an Abstract class

Properties

table_name

The name of the database table

public string $table_name

version

The version of the database table

public string $version

primary_key

The name of the primary column

public string $primary_key

Methods

__construct

Get things started

public __construct(): mixed

get_columns

Returns whitelist of columns

public get_columns(): array

get_column_defaults

Returns the default column values

public get_column_defaults(): array

get

Retrieves a row by the primary key

public get(string $row_id): object

Parameters:

Parameter Type Description
$row_id string The row ID.

get_by

Retrieve a row by a specific column / value

public get_by(string $column, int $row_id): object

Parameters:

Parameter Type Description
$column string The column.
$row_id int The ID of the row.

get_column

Retrieves a specific column's value by the primary key

public get_column(string $column, int $row_id): string

Parameters:

Parameter Type Description
$column string The column.
$row_id int The ID of the row.

get_column_by

Retrieves a specific column's value by the the specified column / value

public get_column_by(string $column, string $column_where, string $column_value): string

Parameters:

Parameter Type Description
$column string The column.
$column_where string The WHERE part of the query.
$column_value string The column value.

insert

Inserts a new row.

public insert(array $data, string $type = ''): int

Parameters:

Parameter Type Description
$data array Array of data.
$type string Type of data to insert.

update

Updates a row in the database.

public update(int $row_id, array $data = array(), string $where = ''): bool

Parameters:

Parameter Type Description
$row_id int The ID of the row.
$data array Array of data.
$where string The WHERE part of the query.

delete

Deletes a row identified by the primary key

public delete(int $row_id): bool

Parameters:

Parameter Type Description
$row_id int The ID of the row to delete.

table_exists

Check if the given table exists

public table_exists(string $table = ''): bool

Parameters:

Parameter Type Description
$table string The table name.

Return Value:

If the table name exists



Automatically generated from source code comments on 2023-02-22 using phpDocumentor and saggre/phpdocumentor-markdown