bitapps / wp-database
A simple orm with wpdb
2.0.0
2026-07-06 06:59 UTC
Requires
- php: >=8.0
Requires (Dev)
This package is auto-updated.
Last update: 2026-07-06 07:39:58 UTC
README
A small ActiveRecord ORM with a fluent query and schema builder on top of
WordPress' $wpdb.
Install
// composer.json "repositories": [ { "type": "vcs", "url": "https://github.com/Bit-Apps-Pro/wp-database" } ]
composer require bitapps/wp-database:dev-main
Quick start
use BitApps\WPDatabase\Model; class Contact extends Model { protected $fillable = ['name', 'email']; public function deals() { return $this->hasMany(Deal::class, 'contact_id', 'id'); } } Contact::insert(['name' => 'Ada', 'email' => 'ada@x.com']); $active = Contact::where('is_active', 1) ->withCount('deals') ->orderBy('name')->asc() ->get(); // Collection of Contact models
Documentation
- Usage guide — models, query builder, relationships, casts, events, transactions, and more.
- Relationships —
hasOne/belongsTo/hasMany/belongsToMany, eager & lazy loading, relation aggregates, and limitations. - Schema builder — table creation, columns, indexes, and migrations.
- Breaking changes — upgrade notes.