berlindb

Implement, debug, and migrate WordPress custom database tables using BerlinDB 3.x.

273|27|Updated Aug 1, 2019
One-click install
npx skills add https://github.com/berlindb/core --skill berlindb-berlindb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: berlindb
Source: https://github.com/berlindb/core/tree/main/skills/berlindb
Command: npx skills add https://github.com/berlindb/core --skill berlindb-berlindb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building custom database tables in WordPress with BerlinDB involves many failure-prone details: correct 3.x namespaces, schema flags that gate query vars, CRUD return-value semantics, relationship declarations, table upgrades, and silent save failures. This Skill provides the operational knowledge to implement, review, debug, and migrate BerlinDB-backed tables correctly. ## Core Features & Use Cases - Schema, Table, Row, and Query guidance: Define the four-class integration pattern with correct column flags (allow_null, sortable, in/not_in), string table versions, and upgrade callbacks. - Relationships and meta tables: Declare belongs_to/has_many relationships (single, composite, and conditioned), prime caches with with, filter via relation, and build custom meta tables with the Meta preset. - Debugging and migration: Diagnose silent insert/update failures, wrong primary-key usage, stuck table upgrades, and migrate BerlinDB 2.x code to 3.x namespaces and APIs. - Use Case: A plugin developer's add_item() call returns false with no SQL error. The Skill walks through checking allow_null flags, capability reduction (wp_set_current_user(1) in tests), and the structured get_logs() output to find the rejected column. ## Quick Start Ask the assistant to help you define a BerlinDB Schema, Table, Row, and Query for a new WordPress custom table, or to debug a failing BerlinDB insert or migration.

Frequently Asked Questions about berlindb

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a custom database table in WordPress with BerlinDB?

Define four classes: a Schema subclass with $columns and $indexes, a Table subclass with $name, $version, and $schema, a Row subclass with public properties, and a Query subclass with $table_schema and $item_shape. Then call maybe_upgrade() on the Table from an activation path.

Why does BerlinDB add_item() return false with no SQL error?

Validation usually stopped the write before SQL ran. Common causes are passing null to a column without 'allow_null' => true, an invalid value for the column type, or capability reduction stripping fields. Inspect $query->get_logs() and $wpdb->last_error to find the rejected column.

How do I migrate BerlinDB 2.x code to 3.x?

Update namespaces to BerlinDB\Database\Kern\Schema, Table, Query, and Row instead of the old BerlinDB\Database paths. Replace Table::set_schema() overrides with a $schema class property, use get_create_table_string() instead of to_string(), and note PHP 8.1 is now required.

Does BerlinDB support relationships between custom tables?

Yes, version 3.1.0 supports belongs_to and has_many relationships declared in a column's relationships array, including composite keys and conditioned polymorphic relationships. Use get_related() to fetch related rows, with to prime caches, and the relation query var to filter.

Why does get_found_items() return the wrong total for pagination?

The no_found_rows query var defaults to true, so no separate COUNT(*) query runs and get_found_items() returns only the current page count. Pass 'no_found_rows' => false explicitly to get the true total for pagination.

What are the limitations of composite primary keys in BerlinDB?

Composite primary keys are intended for junction tables only. Item meta is unsupported, get_item() and copy_item() work with single-column keys only, and add_item() uses the first key column for its returned ID. Prefer a single-column key plus a composite UNIQUE index.