Skip to content

bit-apps-pro/wp-database

Repository files navigation

wp-database

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.
  • RelationshipshasOne/belongsTo/hasMany/belongsToMany, eager & lazy loading, relation aggregates, and limitations.
  • Schema builder — table creation, columns, indexes, and migrations.
  • Breaking changes — upgrade notes.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages