PHPackages                             juksta/laravel-raw-sql-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. juksta/laravel-raw-sql-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

juksta/laravel-raw-sql-builder
==============================

Create and operate raw sql as string with parameters support

01PHP

Since Nov 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/juksta-gdpr/laravel-raw-sql-builder)[ Packagist](https://packagist.org/packages/juksta/laravel-raw-sql-builder)[ RSS](/packages/juksta-laravel-raw-sql-builder/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Raw SQL Builder
=======================

[](#laravel-raw-sql-builder)

Laravel Raw SQL Builder is a library that helps build raw sql text queries. It's built on top of the Eloquent query builder.

Usage
-----

[](#usage)

```
        $bindings = [];

        $fields = "
            b.id,
            b.name,
            pp.name as product_plan,
            b.created_at
        ";

        $sql = "
            SELECT :fields
            FROM
                business b
                LEFT JOIN business_unit bu ON (bu.business_id = b.id AND bu.active = 1)
        ";

        $queryBuilder = $this->getQueryBuilder();

        $queryBuilder->where(new Expression('b.name'), 'like', '%LTD%');
        $sql .= $this->compileWheresSql($queryBuilder) . ' ';

        $bindings += $queryBuilder->getBindings();

        if ($condition) {
            $orderColumn = 'b.name';
            $orderDirection = 'ASC';

            $queryBuilder->orderBy($orderColumn, $orderDirection);
        }

        if (true) {
            $offset = 10;
            $length = 10;
            $queryBuilder->offset($offset);
            $queryBuilder->limit($length);
        }

        $totalSql = $sql;

        $sql .= $this->compileOrdersSql($queryBuilder) . ' ';
        $sql .= $this->compileLimitSql($queryBuilder) . ' ';
        $sql .= $this->compileOffsetSql($queryBuilder);

        $sql = trim(str_replace(":fields", $fields, $sql));

        $items = DB::select(DB::raw($sql), $bindings);
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e0e5d6a1e55f2842b9480ebeebe5ae4d953af12ce8dac2c5b1aef9f4bbdfd90?d=identicon)[ishenkoyv](/maintainers/ishenkoyv)

---

Top Contributors

[![ishenkoyv](https://avatars.githubusercontent.com/u/665562?v=4)](https://github.com/ishenkoyv "ishenkoyv (1 commits)")

### Embed Badge

![Health badge](/badges/juksta-laravel-raw-sql-builder/health.svg)

```
[![Health](https://phpackages.com/badges/juksta-laravel-raw-sql-builder/health.svg)](https://phpackages.com/packages/juksta-laravel-raw-sql-builder)
```

###  Alternatives

[magyarjeti/laravel-lipsum

Lorem ipsum generator for Laravel Framework

1617.9k](/packages/magyarjeti-laravel-lipsum)

PHPackages © 2026

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