*** # Database Database base class * Full name: `\CourierNotices\Core\Database` * This class is an **Abstract class** ## Properties ### table_name The name of the database table ```php public string $table_name ``` *** ### version The version of the database table ```php public string $version ``` *** ### primary_key The name of the primary column ```php public string $primary_key ``` *** ## Methods ### __construct Get things started ```php public __construct(): mixed ``` *** ### get_columns Returns whitelist of columns ```php public get_columns(): array ``` *** ### get_column_defaults Returns the default column values ```php public get_column_defaults(): array ``` *** ### get Retrieves a row by the primary key ```php 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 ```php 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 ```php 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 ```php 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. ```php 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. ```php 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 ```php 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 ```php public table_exists(string $table = ''): bool ``` **Parameters:** | Parameter | Type | Description | |-----------|------|-------------| | `$table` | **string** | The table name. | **Return Value:** If the table name exists *** *** > Automatically generated on 2024-08-26