PHPackages                             alemran/wp-query-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. alemran/wp-query-builder

ActiveLibrary

alemran/wp-query-builder
========================

The query builder for WordPress

v1.0.1(6y ago)773MITPHPPHP &gt;=7.0.0

Since May 16Pushed 6y agoCompare

[ Source](https://github.com/emrancu/wpQueryBuilder)[ Packagist](https://packagist.org/packages/alemran/wp-query-builder)[ Docs](https://github.com/emrancu/wpQueryBuilder)[ RSS](/packages/alemran-wp-query-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

wpQueryBuilder
==============

[](#wpquerybuilder)

wpQueryBuilder provides a convenient, fluent interface to run database queries. It can be used to perform most database operations in your application.

Instalation
===========

[](#instalation)

 via Composer: `composer require alemran/wp-query-builder`

 # Example ```

    require 'vendor/autoload.php';

    use wpQueryBuilder\DB;

    DB::table('demo')->first()

```

**DB Functions** 1. Retrieving A Single Row
    `  DB::table('users')->first();`
2. Retrieving A multiple Row
    `  DB::table('users')->get();`

1. `where($column, $value )` : ```
    DB::table('users')
         ->where('id', 1)
         ->get()
    ```

    ```
    DB::table('users')
         ->where(function($query){
           $query->where('id', 1);
           $query->orWhere('name', "name");
         })
         ->get()
    ```
2. `orWhere($column, $value)` : ```
    DB::table('users')
         ->where('id', 1)
         ->orWhere('name', "name")
         ->get()
    ```

    ```
    DB::table('users')
         ->where('id', 1)
         ->orWhere(function($query){
             $query->where('field', 'value);
             $query->where('field', 'value);
             })
         ->first()
    ```
3. `whereRaw($query)` : ```
    DB::table('users')
         ->whereRaw('id = 1')
         ->first()
    ```
4. `orWhereRaw($query)` : ```
    DB::table('users')
         ->whereRaw('id = 1')
         ->orWhereRaw('id = 1')
         ->first()
    ```
5. `orderBy($columns, $direction)` : ```
    DB::table('users')
         ->orderBy('id', 'desc')
    ```

    ```
    DB::table('users')
         ->orderBy('id,name', 'desc')
    ```
6. `groupBy($columns)` : ```
    DB::table('users')
         ->groupBy('id')
    ```

    ```
    DB::table('users')
         ->groupBy('id,name')
    ```
7. `limit($number)` : ```
    DB::table('users')
         ->where('id', 1)
         ->limit(number)->get()
    ```
8. `offset($number)` : ```
    DB::table('users')
         ->where('id', 1)
         ->limit(number)->offset(number)->get()
    ```
9. `select($fields)` : ```
    DB::table('users')
         ->select('id,name')
            ->get()
    ```
10. `insert($data)` : ```
    DB::table('users')
         ->insert(['name' => "demo"])
    ```
11. `update($data,$where)` : ```
    DB::table('users')
         ->where('id', 1)
         ->update(['name' => "demo"])
    ```
12. `delete($where)` : ```
    DB::table('users')
         ->where('id', 1)
         ->delete()
    ```
13. `join($table, $first, $operator = null, $second = null) (INNER JOIN)`: ```
    DB::table('demo_notes as n')
            ->join('demo_users as u', 'u.id', '=', 'n.user_id')
            ->first()

    ```

    ```
    DB::table('demo_notes as n')
            ->join('demo_users as u', function($query){
              $query->on( 'u.id', '=', 'n.user_id')
              $query->orOn( 'u.id', '=', 'n.user_id')
            })
            ->first()

    ```

    ```
    DB::table('demo_notes as n')
            ->join('demo_users as u', function($query) use($request){
              $query->on( 'u.id', '=', 'n.user_id')
              $query->onWhere( 'u.id', '=', $request->id)
            })
            ->first()

    ```

    > Note: Must use table alias for using join or leftJoin.
14. `leftJoin($table, $first, $operator = null, $second = null) (LEFT JOIN)`:  **Same as join()**
15. `transaction()`: ```
    DB::startTransaction(function(){
        DB::table('demo_notes')
          ->insert([
             "note" => "Hello",
           ]);
    })
    ```

    ```
    DB::startTransaction(function(DB $query){
        $query->table('demo_notes')
          ->insert([
             "note" => "Hello",
           ]);
    })
    ```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2193d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1bc29c6227fdfa1f1980c440796e0aa8f249c549be4a75c772c2c67102f5ae4b?d=identicon)[alemran](/maintainers/alemran)

---

Top Contributors

[![emrancu](https://avatars.githubusercontent.com/u/11002290?v=4)](https://github.com/emrancu "emrancu (8 commits)")

---

Tags

query builderQuery builder for WordPressWordPress Query Builder

### Embed Badge

![Health badge](/badges/alemran-wp-query-builder/health.svg)

```
[![Health](https://phpackages.com/badges/alemran-wp-query-builder/health.svg)](https://phpackages.com/packages/alemran-wp-query-builder)
```

###  Alternatives

[j4mie/idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5

2.0k1.5M29](/packages/j4mie-idiorm)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)[usmanhalalit/pixie

A lightweight, expressive, framework agnostic query builder for PHP.

6872.2M15](/packages/usmanhalalit-pixie)[gmostafa/php-graphql-client

GraphQL client and query builder.

3217.6M25](/packages/gmostafa-php-graphql-client)[foolz/sphinxql-query-builder

A PHP query builder for SphinxQL and ManticoreQL with MySQLi and PDO drivers.

3232.2M32](/packages/foolz-sphinxql-query-builder)[yiisoft/db

Database abstraction layer and query builder

187468.4k30](/packages/yiisoft-db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
