PHPackages                             pyjac/orm - 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. pyjac/orm

ActiveLibrary

pyjac/orm
=========

A simple agnostic ORM that can perform the basic crud database operations.

07[1 PRs](https://github.com/andela-joyebanji/PotatoORM/pulls)

Since Mar 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/andela-joyebanji/PotatoORM)[ Packagist](https://packagist.org/packages/pyjac/orm)[ RSS](/packages/pyjac-orm/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/7b64eafdb3f67de397804f3d7174d298ea25152534c77b99716b47a5e7903ae3/68747470733a2f2f7472617669732d63692e6f72672f616e64656c612d6a6f796562616e6a692f506f7461746f4f524d2e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/andela-joyebanji/PotatoORM) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/f46e0f7b092144d0039c0b7bc5002d2e6b8fbe3e49774bbd1ff124fb2a42ced5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616e64656c612d6a6f796562616e6a692f506f7461746f4f524d2f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/andela-joyebanji/PotatoORM/?branch=develop) [![StyleCI](https://camo.githubusercontent.com/9eba748be2dada0a9e7b65afa02d899890e90eb5e93a16c8f61d7285ed403d2d/68747470733a2f2f7374796c6563692e696f2f7265706f732f35333036303636382f736869656c64)](https://styleci.io/repos/53060668) [![Coverage Status](https://camo.githubusercontent.com/78032c2881fad593511819894a9aae1ec3dfaeafddcb2cee8f3f3551b2534cbf/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f616e64656c612d6a6f796562616e6a692f506f7461746f4f524d2f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/andela-joyebanji/PotatoORM?branch=develop)

Potato ORM
==========

[](#potato-orm)

Potato ORM is a very simple agnostic ORM that can perform the basic CRUD database operations. It is an implementation of the Checkpoint 2 requirement for PHP developers at Andela.

Installation
------------

[](#installation)

Require via composer like so:

```
    composer require pyjac/orm

```

Supported database engines
==========================

[](#supported-database-engines)

```
1. MySQL
2. Postgres
3. SQLite

```

You also need set your environment variables to define your database parameters or create a `.env` file in your project.

```
DRIVER   = sqlite
HOSTNAME = 127.0.0.1
USERNAME = pyjac
PASSWORD = pyjac
DBNAME   = potatoORM
PORT     = 54320

```

Usage
-----

[](#usage)

Models that needs to perform CRUD operations on the database need to extend the `Pyjac\ORM\Model` class. For example:

```
use Pyjac\ORM\Model;

class User extends Model
{

}
```

### Table Names

[](#table-names)

Note that we did not specify which table to use for our `User` model. The plural name of the class will be unless another name is explicitly specified. So, in this case, PotatoORM will assume the `User` model stores records in the users table. You may specify a custom table by defining a table property on your model:

```
use Pyjac\ORM\Model;

class User extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'users';
}
```

**To create a new instance of the User class, you do:**

```
$user = new User();
```

**To create a new record in the database, you do:**

```
$user = new User();
$user->name = "Pyjac";
$user->age = 200;
$user->save();
```

`(Note) The above assumes you've created a table named users with columns id, name and age in the database.`

**To fetch all the Model of the class from the database, you do:**

```
$users = User::getAll();
var_dump($users);
```

**To find a Model with a specific id in the database, you do:**

```
$user = User::find(3);
```

**To delete a Model from the database, you do:**

```
$user = User::destroy(1);
```

**Updating an existing Model in the database:**

```
$user = User::find(1);
$user->name = "Nandaa";
$user->save();
```

`NB: The save() method checks first to see if the id exists. if yes, it calls the update method else calls the create method`

### Exceptions

[](#exceptions)

- `DatabaseDriverNotSupportedException`: This exception is thrown when database driver in not supported.
- `ModelNotFoundException`: This exception is thrown when model the find method is trying to get from the database does not exist.

Security
--------

[](#security)

If you discover any security related issues, please email [Oyebanji Jacob](oyebanji.jacob@andela.com) or create an issue.

Credits
-------

[](#credits)

[Oyebanji Jacob](https://github.com/andela-joyebanji)

License
-------

[](#license)

### The MIT License (MIT)

[](#the-mit-license-mit)

Copyright (c) 2016 Oyebanji Jacob

> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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/4a099d5df93214acf3c8455392d1c9a5490a5e0a73aec33985a5664f152bb373?d=identicon)[andela-joyebanji](/maintainers/andela-joyebanji)

### Embed Badge

![Health badge](/badges/pyjac-orm/health.svg)

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

PHPackages © 2026

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