vundi / potato-orm
An ORM package that allows you to perform basic CRUD operations on any database
Installs: 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
pkg:composer/vundi/potato-orm
Requires
- php: >=5.6
- guzzlehttp/guzzle: ~6.0
- vlucas/phpdotenv: ^2.2
Requires (Dev)
- phpunit/phpunit: ^5.2
- satooshi/php-coveralls: ^0.7.0
This package is not auto-updated.
Last update: 2025-12-04 06:18:22 UTC
README
POTATO ORM is a custom ORM that allows you to perform all CRUD operations on a table when working with any database
Install
Installation via Composer
$ composer require vundi/potato-orm
Usage
Configuration SQL databases
NOTE: Load you connection variables from the .env file in the root folder. If you do not have a .env file in your root folder or don't know about it, please read this phpdotenv project.
Provide Database host, database user, database password and the type in the .env file. Once you provide the right values a Database connection will be established.
// Load the `.env` variables for the project // Check the `.env.example` file in the root of the project to see the environment variables needed. $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load();
Once we have a connection, we create a model class which extends Model. Inside the model class set the entity table name
require 'vendor/autoload.php'; use Vundi\Potato\Model; use Vundi\Potato\Exceptions\NonExistentID; use Vundi\Potato\Exceptions\IDShouldBeNumber; class User extends Model { protected static $entity_table = 'Person'; }
Database interactions
// create a new user $user = new User; $user->name = "Kevin Karugu"; $user->age = 23; $user->company = "Andela"; $user->save();
Get all users from the users table
$users = User::findAll(); // Returns an array of the users found in the db
Get a single user from the users table
$user = User::find(2); // will return user with an ID of 2
Edit an existing user
$user = User::find(2); $user->name = "Devy Kerr"; $user->company = "Suyabay"; $user->update();
Delete a user
//Will remove a user from the database table User::remove(2); // 2 represents the id of the user to be removed
Credits
License
The MIT License (MIT). Please see License File for more information.