\Omega\Database\Adapter MysqlAdapter

MySQL adapter class.

The MysqlDatabaseAdapter class is an implementation of the abstract AbstractDatabaseAdapter and is specifically tailored for MySQL database connections. This adapter provides mysql-specific database management features while inheriting the common database functionality defined in the parent class.

Summary

Methods
Properties
Constants
__construct
checkIfDatabaseExists
query
createTable
alterTable
getTables
dropTables
pdo
hasTable
pdo
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
database
No private constants found

Properties

$pdo

$pdo : \Pdo

Pdo instance.

Type

Pdo — Holds an instance of Pdo.

$database

$database : string

Database name.

Type

string — Holds the database name.

Methods

__construct()

__construct(string  $dsn, string  $username = '', string  $password = '') : mixed

Constructs a new database adapter instance.

Parameters

string $dsn

The Data Source Name (DSN) for the database connection.

string $username

The username for the database connection.

string $password

The password for the database connection.

Throws

\Omega\Database\Exception\AdapterException

if the PDO extension is not installed or enabled.

\Omega\Database\Exception\ConnectionException

if the database connection fails.

\PDOException

Returns

mixed —

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.

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.

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.

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.

Returns

string[] —

Returns an array of table names available on this connection.

dropTables()

dropTables() : int|bool

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

Returns

int|bool —

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

pdo()

pdo() : \Pdo

Get the underlying PDO instance for this connection.

Throws

\Omega\Database\Exception\AdapterException

if pdo extension is not installed or not enabled.

Returns

\Pdo —

Returns the current PDO instance that represents the database connection.

hasTable()

hasTable(string  $name) : bool

Check if a table exists on this connection.

Parameters

string $name

The name of the table to check.

Returns

bool —

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