PHPackages                             roy404/eloquent - 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. [Database &amp; ORM](/categories/database)
4. /
5. roy404/eloquent

ActiveLibrary[Database &amp; ORM](/categories/database)

roy404/eloquent
===============

Eloquent is the default ORM (Object-Relational Mapping). It provides a simple ActiveRecord implementation for working with your database. With Eloquent, you can define database models as classes, and interact with the database using these models, rather than writing raw SQL queries.

2.7.4(7mo ago)2254[2 issues](https://github.com/roycanales17/Database-ORM/issues)1MITPHPPHP ^8.1

Since Feb 18Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/roycanales17/Database-ORM)[ Packagist](https://packagist.org/packages/roy404/eloquent)[ RSS](/packages/roy404-eloquent/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (53)Used By (1)

ELOQUENT CLASS
==============

[](#eloquent-class)

Install the bundle using Composer:

```
composer require roy404/eloquent

```

DOCUMENTATION
=============

[](#documentation)

The Eloquent class is a database query builder that provides a fluent interface to create SQL queries.

Methods
-------

[](#methods)

- `table()`: Sets the table for the query.
- `select()`: Adds a column to the select clause.
- `where()`: Adds a where clause to the query.
- `orWhere()`: Adds an OR where clause to the query.
- `orderBy()`: Adds an order by clause to the query.
- `offset()`: Adds an offset clause to the query.
- `limit()`: Adds a limit clause to the query.
- `create()`: Creates a new record in the database.
- `replace()`: Replaces a record in the database.

Model
-----

[](#model)

The Model class extends Eloquent and provides additional methods for interacting with database tables that correspond to models.

- `all(): array`: Retrieves all records from the database table.
- `create(array $binds): int`: Creates a new record in the database table.
- `replace(array $binds): int`: Replaces a record in the database table.
- `find(int $id): array`: Retrieves a record by its primary key.
- `select(...$columns): Eloquent`: Selects specific columns from the database table.
- `where(string $column, mixed $operator_or_value, mixed $value = self::DEFAULT_VALUE): Eloquent`: Adds a where clause to the query.

Return Data
-----------

[](#return-data)

However, these functions are not yet fully implemented; you will need to complete them yourself.

- `lastID()`: int: Returns the last inserted ID from the database.
- `fetch()`: array: Fetches all rows from the result set as an array of arrays.
- `col()`: array: Fetches the first column of all rows from the result set as an array.
- `field()`: mixed: Fetches a single field value from the first row of the result set.
- `row()`: array: Fetches the first row from the result set as an associative array.
- `count()`: int: Returns the number of rows affected by the last SQL statement.

Example Usage
-------------

[](#example-usage)

```
// Define the User class
class User extends Model
{
    protected string $primary_key = 'id';
    protected array $fillable = ['name'];
}

// Create a new user
$userId = User::create([
    'name' => 'Robroy'
]);

// Retrieve a user by ID
$user = User::find($userId);

// Update a user's record
User::where( 'name', 'Robroy' )->update(['name' => 'Robert']);

// Delete a user's record
User::where( 'name', 'Robert' )->delete();

// Another Example
$user = User::select( 'name', 'email', 'contact' )
    ->where( 'name', '', 'robot' )
    ->where( 'email', 'canales.robroy123@gmail.com' )
    ->where( function( \Illuminate\Databases\Eloquent $group ) {
        $group->where( 'contact', '+63 917 130 4494' )
              ->orWhere( 'contact', '216-2944' )
    })
    ->limit( 1 )
    ->row();

// Another Example [2]
DB::table( 'user' )->select( 'name' )->where( 'id', $userId )->field();
```

### YOU WILL NEED TO CHANGE THE LOGIC OF THE FUNCTION BELOW:

[](#you-will-need-to-change-the-logic-of-the-function-below)

`Illuminate\Databases\DB::run()` - We suggest you to create your own class that runs the query with the action provided in the `Return Data list`.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance44

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~12 days

Recently: every ~0 days

Total

52

Last Release

219d ago

Major Versions

v1.2.5 → 2.0.02025-10-23

PHP version history (2 changes)1.0.0PHP ^8.0

v1.1.3PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/542567e23f273798a0a4a752804c792654fe6c3753b53752b1d00b7eff2b8b11?d=identicon)[roycanales](/maintainers/roycanales)

---

Top Contributors

[![roycanales17](https://avatars.githubusercontent.com/u/62797701?v=4)](https://github.com/roycanales17 "roycanales17 (89 commits)")

---

Tags

database-mappingdatabase-modelseloquent-ormmodel-driven-designobject-relational-mappingorm-queriespdophp-database-modelsquery-builderphpplugins

### Embed Badge

![Health badge](/badges/roy404-eloquent/health.svg)

```
[![Health](https://phpackages.com/badges/roy404-eloquent/health.svg)](https://phpackages.com/packages/roy404-eloquent)
```

###  Alternatives

[eftec/pdoone

Minimaist procedural PDO wrapper library

1116.3k9](/packages/eftec-pdoone)[simple-swoole/db

A db component for Simps.

216.8k3](/packages/simple-swoole-db)

PHPackages © 2026

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