\Omega\Database\Adapter DatabaseAdapterInterface

Database Adapter Interface.

The DatabaseAdapterInterface defines the contract for database adapter classes, which provide a set of methods for interacting with a database.

Summary

Methods
Constants
pdo()
checkIfDatabaseExists()
query()
createTable()
alterTable()
getTables()
hasTable()
dropTables()
No public constants found

Methods

pdo()

pdo() : \PDO

Get the underlying PDO instance for this connection.

Returns

\PDO —

Returns the current PDO instance that represents the database connection.

checkIfDatabaseExists()

checkIfDatabaseExists(string  $host, string  $port, string  $username, string  $password) : void

Check if database exists, otherwise create it.

Parameters

string $host

Holds the host of the database.

string $port

Holds the port number.

string $username

Holds the username for the connection.

string $password

Holds the password for the connection.

Returns

void —

query()

query() : \Omega\Database\QueryBuilder\AbstractQueryBuilder

Start a new query builder on this connection.

This method initializes a new query builder instance for building SQL queries.

Returns

\Omega\Database\QueryBuilder\AbstractQueryBuilder —

An instance of the AbstractQueryBuilder class for constructing SQL queries.

createTable()

createTable(string  $table) : \Omega\Database\Migration\AbstractMigration

Start a new migration to create a table on this connection.

This method begins a new migration process for creating a database table.

Parameters

string $table

The name of the table to create.

Returns

\Omega\Database\Migration\AbstractMigration —

Returns an instance of the AbstractMigration class for managing table creation.

alterTable()

alterTable(string  $table) : \Omega\Database\Migration\AbstractMigration

Start a new migration to modify an existing table on this connection.

This method initiates a new migration process for modifying an existing database table.

Parameters

string $table

The name of the table to modify.

Returns

\Omega\Database\Migration\AbstractMigration —

Returns an instance of the AbstractMigration class for managing table alterations.

getTables()

getTables() : string[]

Get the list of table names on this connection.

Retrieve an array containing the names of all tables available on this database connection.

Returns

string[] —

Returns an array of table names available on this connection.

hasTable()

hasTable(string  $name) : bool

Check if a table exists on this connection.

Determine whether a specified table exists on the database connection.

Parameters

string $name

The name of the table to check.

Returns

bool —

Returns true if the specified table exists, otherwise returns false.

dropTables()

dropTables() : int|bool

Drop all tables in the current database. Use with caution.

This method is used to delete all tables in the current database. Exercise caution as data loss is irreversible.

Returns

int|bool —

Returns 1 if all tables are successfully dropped, or false if any issues occur during the process.