PHPackages                             seguncodes/smyorm - 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. seguncodes/smyorm

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

seguncodes/smyorm
=================

SmyORM is a PHP Object-relational mapping (ORM) that allows developers to write code in simple programming languages of their choice instead of using SQL to access, add, update, and delete data and schemas in the respective database.

v1.0(2y ago)14MITPHP

Since May 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/SegunCodes/SmyORM)[ Packagist](https://packagist.org/packages/seguncodes/smyorm)[ RSS](/packages/seguncodes-smyorm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

SMYORM
======

[](#smyorm)

- [Description](#description)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    1. [Instantiating the ORM](#instantiate-orm)
    2. [Query Builders](#query-builders)
- [Contributing and Vulnerabilities](#contributing-and-vulnerabilities)
- [License](#license)

DESCRIPTION
===========

[](#description)

SmyORM is a PHP Object-relational mapping (ORM) that allows developers to write code in simple programming languages of their choice instead of using SQL to access, add, update, and delete data and schemas in the respective database. It is currently being used by the SmyPhp framework

REQUIREMENTS
============

[](#requirements)

- php 7.3^
- composer

INSTALLATION
============

[](#installation)

```
$ composer require seguncodes/smyorm
```

USAGE
=====

[](#usage)

### Instantiating the ORM

[](#instantiating-the-orm)

Create a Model for each database table eg User.php or Transaction.php; Or a basic file to handle the SQL operations for a specific table. Then instantiate the ORM this way:

`User.php` file

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }
}
```

### Query Builders

[](#query-builders)

The ORM comes with various query builders `save()`The save method saves data into database

`User.php` file

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testSave() {
        // Create a sample object with data
        $data = [
            'name' => 'Joe',
            'email' => 'john@doe.com',
            'role' => 'User'
        ];
        foreach ($data as $attribute => $value) {
            $this->orm->{$attribute} = $value;
        }

        // Call the save() method
        $result = $this->orm->save();
        return $result;
    }
}
```

`findOne()`finds row WHERE argument exists and returns only 1

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testFindOne() {
        // Call the findOne() method
        $result = $this->orm->findOne([
            "id" => 16,
            "name" => "John"
        ]);

        return $result;
    }
}
```

`findOneOrWhere()`This takes in two arguments with the second argument being the OR condition and returns only one result

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testfindOneOrWhere() {
        // Call the findOneOrWhere() method
        $result = $this->orm->findOneOrWhere([
            "id" => 16
        ], [
            "role" => "Admin"
        ]);

        return $result;
    }
}
```

`findAll()`This performs the basic SELECT all functionality

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }
     public function testFindAll() {
        // Call the findAll() method
        $result = $this->orm->findAll();

        return $result;
    }
}
```

`findAllWhere()`This performs the findAll functionality with a WHERE clause

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }
     public function testfindAllWhere() {
        // Call the findAllWhere() method
        $result = $this->orm->findAllWhere([
            "id" => 1
        ]);

        return $result;
    }
}
```

`findAllOrWhere()`This performs the findAll functionality with a WHERE clause with the second argument being the OR condition

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

     public function testfindAllOrWhere() {
        // Call the findAllOrWhere() method
        $result = $this->orm->findAllOrWhere([
            "id" => 13
        ], [
            "name" => "joe"
        ]);

        return $result;
    }
}
```

`count()`This counts the number of columns in a table

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

     public function testCount() {
        // Call the count() method
        $result = $this->orm->count();

        return $result;
    }
}
```

`countWhere()`This counts the number of columns with a WHERE clause

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

     public function testcountWhere() {
        // Call the countWhere() method
        $result = $this->orm->countWhere([
            "id" => 1
        ]);

        return $result;
    }
}
```

`countOrWhere()`This counts the number of columns with a WHERE clause and the second argument being the OR condition

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testcountOrWhere() {
        // Call the countOrWhere() method
        $result = $this->orm->countOrWhere([
            "id" => 13
        ], [
            "id" => 15
        ]);

        return $result;
    }
}
```

`delete()`This takes a WHERE clause and deletes a row or rows

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testdelete() {
        // Call the delete() method
        $result = $this->orm->delete([
            "id" => 1
        ]);

        return $result;
    }
}
```

`deleteOrWhere()`This takes a WHERE clause and the second argument being the OR condition then deletes corresponding row or rows

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testdeleteOrWhere() {
        // Call the countOrWhere() method
        $result = $this->orm->deleteOrWhere([
            "id" => 13
        ], [
            "id" => 15
        ]);

        return $result;
    }
}
```

`update()`This takes two arguments, the data to be updated and the WHERE clause

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

    public function testUpdate() {
        // Call the update() method
        $result = $this->orm->update([
            "name" => "john Doe"
        ], [
            "id" => 13
        ]);

        return $result;
    }
}
```

`updateOrWhere()`This takes three arguments, the data to be updated, a WHERE clause and an OR condition

```
require_once __DIR__ . '/vendor/autoload.php';
use SmyORM\SmyORM\Orm;

class User{
    private $orm;

    public function __construct() {
        $this->setUp();
    }

    public function setUp(): void {
        $db = new \PDO('mysql:host=localhost;dbname=yourDatabaseName', 'username', 'password');

        // Create a concrete class that extends the ORM class
        $this->orm = new class($db) extends Orm {
            public function tableName(): string {
                return 'users'; // the name of the table that this model references
            }

            public function attributes(): array {
                return ['name', 'email', 'role']; // attributes of the table
            }
        };
    }

     public function testupdateOrWhere() {
        // Call the updateOrWhere() method
        $result = $this->orm->updateOrWhere([
            "name" => "Joe doe"
        ], [
            "id" => 17,
            "role" => "User"
        ], [
            "id" => 13,
            "role" => "Admin"
        ]);

        return $result;
    }
}
```

Contributing &amp; Vulnerabilities
==================================

[](#contributing--vulnerabilities)

If you would like to contribute or you discover a security vulnerability in the SmyORM, your pull requests are welcome. However, for major changes or ideas on how to improve the library, please create an issue.

License
=======

[](#license)

The SmyORM is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

1084d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48e055148e3b3caf741b22179aaf227c40a91f6f8790a968f4ffe4b441daa1f6?d=identicon)[SegunCodes](/maintainers/SegunCodes)

---

Top Contributors

[![SegunCodes](https://avatars.githubusercontent.com/u/89858483?v=4)](https://github.com/SegunCodes "SegunCodes (7 commits)")

---

Tags

php ormsmyphpsmyorm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/seguncodes-smyorm/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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