-
Notifications
You must be signed in to change notification settings - Fork 0
Database
github-actions[bot] edited this page Aug 26, 2024
·
12 revisions
Database base class
- Full name:
\CourierNotices\Core\Database
- This class is an Abstract class
The name of the database table
public string $table_name
The version of the database table
public string $version
The name of the primary column
public string $primary_key
Get things started
public __construct(): mixed
Returns whitelist of columns
public get_columns(): array
Returns the default column values
public get_column_defaults(): array
Retrieves a row by the primary key
public get(string $row_id): object
Parameters:
Parameter | Type | Description |
---|---|---|
$row_id |
string | The row ID. |
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. |
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. |
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. |
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. |
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. |
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. |
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 on 2024-08-26