Skip to content

Connection Interface

John James Jacoby edited this page May 27, 2026 · 1 revision

Connection Interface

BerlinDB\Database\Interfaces\Connection is the contract BerlinDB uses instead of depending directly on wpdb.

The bundled WordPress implementation is BerlinDB\Database\Adapters\Wpdb.

Query Methods

public function prepare( string $query, mixed ...$args ): string|null;
public function query( string $query ): int|bool;
public function get_var( string|null $query = null, int $column_offset = 0, int $row_offset = 0 ): string|null;
public function get_row( string|null $query = null, string $output = 'OBJECT', int $y = 0 ): array|object|null;
public function get_results( string|null $query = null, string $output = 'OBJECT' ): array|object|null;
public function get_col( string|null $query = null, int $column_offset = 0 ): array;

Write Methods

public function insert( string $table, array $data, array|string|null $format = null ): int|false;
public function update( string $table, array $data, array $where, array|string|null $format = null, array|string|null $where_format = null ): int|false;
public function delete( string $table, array $where, array|string|null $where_format = null ): int|false;

WordPress-Compatible Helpers

public function esc_like( string $text ): string;
public function suppress_errors( bool $suppress = true ): bool;
public function get_blog_prefix( int|null $blog_id = null ): string;
public function get_insert_id(): int;
public function get_charset(): string;
public function get_collation(): string;

Table Registry

public function get_table_prefix( string $key ): string;
public function set_table_prefix( string $key, string $value ): void;
public function register_table( string $group, string $name ): void;

Custom adapters should preserve the behavior BerlinDB expects from wpdb, especially around prepared placeholders, prefixes, and insert IDs.

Clone this wiki locally