A small ActiveRecord ORM with a fluent query and schema builder on top of
WordPress' $wpdb.
composer require bitapps/wp-database:dev-mainuse 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- 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.