Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (29) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2015-12-18 (10 months ago) | Not enough user ratings | Total: 114 This week: 1 | All time: 8,401 This week: 1,047 |
Version | License | PHP version | Categories | |||
potato-orm 1.0.0 | BSD License | 5 | PHP 5, Databases, Design Patterns |
Description | Author | ||||||||
This package can store and retrieve objects in databases using ORM. |
|
Potato-ORM is a package that manages the CRUD operation of database. Potato-ORM currently supports MYSQL
, POSTGRES
and SQLITE
Database.
PHP 5.5+ and Composer are required.
Via Composer
$ composer require ibonly/potato-orm
$ composer install
namespace Ibonly\PotatoORM
Create a Class
that correspond to the singular form of the table name in the database. i.e.
<?php
namespace Ibonly\PotatoORM;
class User extends Model
{
}
?>
The Model
class contains getAll()
, where($field, $value)
, find($value)
, save()
and detroy($id)
methods.
<?php
use Ibonly\PotatoORM\User;
$sugar = new User();
echo $sugar->getAll();
?>
Return type = JSON
<?php
use Ibonly\PotatoORM\User;
$sugar = new User();
echo $sugar->where($field, $value);
?>
Return type = JSON
<?php
use Ibonly\PotatoORM\User;
$insert = User::find(1);
$insert->password = "password";
echo $insert->save()
?>
To return custom message, wrap the `save()` method in an `if statement`
Return type = Boolean
<?php
use Ibonly\PotatoORM\User;
$insert = new User();
$insert->id = NULL;
$insert->username = "username";
$insert->email = "example@example.com";
$insert->password = "password";
echo $insert->save();
?>
To return custom message, wrap the `save()` method in an `if statement`
Return type = Boolean
<?php
use Ibonly\PotatoORM\User;
$insert = User::destroy(2);
die($insert);
?>
Return type = Boolean
Its is also possible to create Database Table with the Schema
class. The table name will be specified in the
createTable($name)
method.
<?php
use Ibonly\PotatoORM\Schema;
$user = new Schema;
$user->field('increments', 'id');
$user->field('strings', 'username');
$user->field('strings', 'name', 50);
$user->field('integer', 'age');
$user->field('primaryKey', 'id');
echo $table->createTable('players');
?>
Return type = Boolean
Foreign Key
```
$user->field('foreignKey', 'id', 'users_id');
```
The reference table `(users)` and field `(id)` will be written as `(users_id)`
Unique
```
$user->field('unique', 'email')
```
$ vendor/bin/phpunit test
To contribute and extend the scope of this package, Please check out CONTRIBUTING file for detailed contribution guidelines.
Potato-ORM is created and maintained by Ibraheem ADENIYI
.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (1 file, 4 directories) | ||||
test (3 files, 1 directory) | ||||
.env.example | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONTRIBUTING.md | Data | Auxiliary data | ||
LICENCE | Lic. | License | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
Database (2 files) | ||||
Exceptions (7 files) | ||||
Helper (4 files) | ||||
Interface (4 files) | ||||
User.php | Class | Class source |
Files | / | src | / | Database |
File | Role | Description |
---|---|---|
DatabaseQuery.php | Class | Class source |
DBConfig.php | Class | Class source |
Files | / | src | / | Exceptions |
File | Role | Description |
---|---|---|
ColumnNotExistExeption.php | Class | Class source |
DataAlreadyExistException.php | Class | Class source |
DataNotFoundException.php | Class | Class source |
EmptyDatabaseException.php | Class | Class source |
ErrorInsertingException.php | Class | Class source |
InvalidConnectionException.php | Class | Class source |
TableDoesNotExistException.php | Class | Class source |
Files | / | src | / | Helper |
File | Role | Description |
---|---|---|
GetData.php | Class | Class source |
Inflector.php | Class | Class source |
Model.php | Class | Class source |
Schema.php | Class | Class source |
Files | / | src | / | Interface |
File | Role | Description |
---|---|---|
DatabaseQueryInterface.php | Class | Class source |
GetDataInterface.php | Class | Class source |
ModelInterface.php | Class | Class source |
SchemaInterface.php | Class | Class source |
Files | / | test |
File | Role | Description | ||
---|---|---|---|---|
stubs (1 file) | ||||
DatabaseQueryTest.php | Test | Unit test script | ||
ModelTest.php | Test | Unit test script | ||
SchemaTest.php | Test | Unit test script |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.