2017 © Pedro Peláez
 

library keep

Do a lot with very little, an elegant ORM for PHP.

image

keeporm/keep

Do a lot with very little, an elegant ORM for PHP.

  • Tuesday, May 1, 2018
  • by EdsonOnildo
  • Repository
  • 0 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

activerecord.php

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Implementação do padrão de projeto active record em PHP, (*2)

Table of Contents

Prerequisites

  • PHP 7.1+
  • PDO driver for your respective database

Supported Databases

  • MySQL
  • SQLite
  • PostgreSQL
  • Oracle

Installation

Require via composer, (*3)

``` sh $ composer require edsononildo/orm, (*4)


Create an **index.php** file and require the autoload.php of composer ```php <?php include 'vendor/autoload.php';

After that, let's to do all necessary configuration, (*5)

use Bonfim\ActiveRecord\ActiveRecord;

ActiveRecord::config('mysql:host=localhost;dbname=testdb', 'username', 'password');

Basic CRUD

Retrieve

These are your basic methods to find and retrieve records from your database:, (*6)

// Retrieve all records
$posts = Post::all();

// Retrieve records with specific keys
$posts = Post::select(['title']);

// Find records with a condition
$posts = Post::find('WHERE id = ?', [1]);

Create

Here we create a new post by instantiating a new object and then invoking the save() method:, (*7)

$post = new Post();
$post->title = 'My first blog post!!';
$post->author_name = 'Edson Onildo';
$post->save();
INSERT INTO `posts` (`title`, `author_name`) VALUES ("My first blog post!!", "Edson Onildo");

Update

To update you would just need to find a record first and then change one of its attributes., (*8)

$post = Post::find('WHERE `id` = ?', [1])[0];
echo $post->title; // 'My first blog post!!'
$post->title = 'Some title';
$post->save();
UPDATE `posts` SET title='Some title' WHERE id=1;

Delete

Deleting a record will not destroy the object. This means that it will call sql to delete the record in your database but you can still use the object if you need to., (*9)

$post = Post::find('WHERE `id` = ?');
$post->delete();
DELETE FROM `posts` WHERE id=1;

Change log

Please see CHANGELOG for more information on what has changed recently., (*10)

Testing

bash $ composer test, (*11)

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*12)

Security

If you discover any security related issues, please email inbox.edsononildo@gmail.com instead of using the issue tracker., (*13)

Credits

License

The MIT License (MIT). Please see License File for more information., (*14)

The Versions

01/05 2018

dev-master

9999999-dev https://github.com/EdsonOnildoJR/Keep-ORM

Do a lot with very little, an elegant ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

01/05 2018

v1.0.0

1.0.0.0 https://github.com/EdsonOnildoJR/Keep-ORM

Do a lot with very little, an elegant ORM for PHP.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires