PHPackages                             elchroy/potatoorm - 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. elchroy/potatoorm

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

elchroy/potatoorm
=================

A simple php database object relational mapping package.

08[1 PRs](https://github.com/elchroy/PotatoORM/pulls)PHP

Since Apr 1Pushed 10y agoCompare

[ Source](https://github.com/elchroy/PotatoORM)[ Packagist](https://packagist.org/packages/elchroy/potatoorm)[ RSS](/packages/elchroy-potatoorm/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Coverage Status](https://camo.githubusercontent.com/37ccff80f1f869315989e779306289844da8d3f51eec78d1256aee2a53ca6a4f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f616e64656c612d63656c697368612d77696777652f506f7461746f4f524d2f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/andela-celisha-wigwe/PotatoORM?branch=develop)[![StyleCI](https://camo.githubusercontent.com/2870a9e4c816c1f34c044b0c077bbf1531b09d4070937c716854c1cd8a90ba06/68747470733a2f2f7374796c6563692e696f2f7265706f732f35333134303438392f736869656c64)](https://styleci.io/repos/53140489)[![Build Status](https://camo.githubusercontent.com/45e73a6eca93b63a4cf8bec66034cd62bcf3081053222223f0d411c21efae631/68747470733a2f2f7472617669732d63692e6f72672f616e64656c612d63656c697368612d77696777652f506f7461746f4f524d2e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/andela-celisha-wigwe/PotatoORM)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6ecf7dfe3748f78764a0e7f9879144662feff9e707062fbfc69752eac76c14fc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616e64656c612d63656c697368612d77696777652f506f7461746f4f524d2f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/andela-celisha-wigwe/PotatoORM/?branch=develop)

PotatoORM
=========

[](#potatoorm)

A simple php database object relational mapping package.

\##Installation

To run this package, you must have [PHP 5.5+](http://http://php.net/) and [Composer](https://getcomposer.org/) installed.

First download the package.

`$ composer require Elchroy/PotatoORM`

Install Composer.

`$ composer install`

\##Set Up Configurations

This package supports the following database engines

- MySQL
- SQLite3

To start using this package ensure that you have already setup a database (either of the above).

- A database has been set up. The database should be compatible with `PDO`.

From the root of the application, open (or create) a file named `config.ini`.

### For MySQL

[](#for-mysql)

If the preferred database is `MySQL`, edit the `config.ini` file like below.

```
[database]
host = localhost
username = username_of_database
password = ****
dbname = name_of_database
adaptar = mysql

```

### For SQLite3

[](#for-sqlite3)

If the preferred database is `SQLite3`, edit the `config.ini` file like below.

```
[database]
adapter = sqlite
sqlite_file = name_of_database_file

```

***For SQLite3 database, ensure to store the database file in root of the appllication, same directory as the `config.ini` file.***

Once you have setup a working database, ensure to have a table in the database. Create a table unless already created.

- Note that the table name must be the same with the desired class. Also the table name must be in lowercase.\*
- The table must have a column named `id` with `int` value type and must be set as the primary key of the table. Otherwise, some errors might be encountered.

The following simple SQL query will create a `book` table with 4 columns.

`CREATE TABLE 'book' (id int NOT NULL AUTOINCREMENT PRIMARY, title varchar(255), author varchar(255)), pages int`.

At this point, the package is ready to communicate with the database and the table.

### Usage

[](#usage)

\#####Create a custom class to extend the `PotatoModel` class.

```
class Book extends PotatoModel
{

}

```

The class name has to be the same with the table in the database that you have setup.

\#####Make a new instance of the class.

```
$book1 = new Book();

$book2 = new Book();

```

\#####Define some properties of the class that should be save in the database table.

Ensure that the properties defined have the same name as the columns of the database table.

```
// Add a first book
$book1->title = "Parry Holter : Cage of Umpires";
$book1->author = "Elchroy Cresly";
$bolt1->pages = 350;

// Add a second book
$book2->title = "Under Mountains";
$book2->author = "Zendel Shezery";
$bolt2->pages = 350;

```

\#####Save the new record in the table.

```
// Save the two new books.
$book1->save();
$book2->save();

```

\#####Find the record from the database.

```
// Find the book with ID of 2.
$book = Book::find(2);
echo $book->title;
==> "Under Mountains"
echo $book->author;
==> "Zendel Shezery"
echo $book->pages;

```

\#####Update a record in the database.

```
$book = Book::find(2); // '2' is the ID of the book to be found.
$book->author = "Sia Merica" // Edit the author of the book.
$book->save(); // Save the book with the new author.

// Check if the book has been updated.
$b = Book::find(2); // The same book with the same ID.
echo $b->title;
==> "Under Mountains"
echo $b->author;
==> "Sia Merica"

```

\#####Delete a record from the database.

```
$book = Book::destroy(2); // '2' is the ID of the book to be deleted.

// The book has been deleted and an exception is thrown.
$b = Book::find(2); // 2 is the ID of the book that was deleted.

Record 2 : Not found found in this table (book).;
...

```

\##Test

To test this package, you can use [PHPUnit](https://phpunit.de/), from command line (WindowsOS) or terminal(MacOS).

**Note: Ensure to `cd` to root directory of the application.**

`$ phpunit`

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bce467b2e9ccb6932b24e5a481d764821e3f8758997bd37a4a88351ebeba3abc?d=identicon)[elchroy](/maintainers/elchroy)

---

Top Contributors

[![elchroy](https://avatars.githubusercontent.com/u/17028608?v=4)](https://github.com/elchroy "elchroy (58 commits)")

### Embed Badge

![Health badge](/badges/elchroy-potatoorm/health.svg)

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

###  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.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M545](/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)
