2017 © Pedro Peláez
 

library php-orm

The open source ORM library

image

gigorok/php-orm

The open source ORM library

  • Saturday, October 18, 2014
  • by gigorok
  • Repository
  • 1 Watchers
  • 0 Stars
  • 56 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

# PHP ORM library

The open source ORM library on PHP., (*1)

Introduction

The PHP-ORM follows ActiveRecord architectural pattern., (*2)

More details can be found here., (*3)

Minimum Requirements

  • PHP 5.4+
  • PDO driver for your respective database

Supported Databases

  • MySQL
  • PostgreSQL

Features

  • Finder methods
  • Writer methods
  • Relationships
  • Validations
  • Callbacks
  • Transactions
  • Support for multiple adapters
  • Table's schema

Installation

Use composer to install PHP ORM library. Just add to your composer.json a text below and run the php composer.phar update command to install it:, (*4)

{
    "require": {
        "gigorok/php-orm": "0.2.*"
    }
}

Basic CRUD

Retrieve

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

$post = Post::find(1);
echo $post->title; # 'Test title!'
echo $post->author_id; # 5

# also the same since it is the first record in the db
$post = Post::first();

# finding using a conditions array
$posts = Post::where('name=? or id > ?', array('The Bridge Builder', 100));

Create

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

$post = new Post();
$post->title = 'My first blog post!!';
$post->author_id = 5;
$post->save();
# INSERT INTO `posts` (title,author_id) VALUES('My first blog post!!', 5)

Update

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

$post = Post::find(1);
echo $post->title; # 'My first blog post!!'
$post->title = 'Some real title';
$post->save();
# UPDATE `posts` SET title='Some real title' WHERE id=1

$post->title = 'New real title';
$post->author_id = 1;
$post->save();
# UPDATE `posts` SET title='New real title', author_id=1 WHERE id=1

Destroy

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., (*8)

$post = Post::find(1);
$post->destroy();
# DELETE FROM `posts` WHERE id=1
echo $post->title; # 'New real title'

License

Licensed under the MIT license., (*9)

The Versions

18/10 2014

dev-master

9999999-dev http://github.com/gigorok/php-orm

The open source ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires

orm php

24/04 2014

0.2.3

0.2.3.0 http://github.com/gigorok/php-orm

The open source ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires

orm php

16/02 2014

0.2.2

0.2.2.0 http://github.com/gigorok/php-orm

The open source ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires

orm php

06/02 2014

0.2.1

0.2.1.0 http://github.com/gigorok/php-orm

PHP ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires

05/02 2014

0.2.0

0.2.0.0 http://github.com/gigorok/php-orm

PHP ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires

30/01 2014

0.1.1

0.1.1.0 http://github.com/gigorok/php-orm

PHP ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires

30/01 2014

0.1.0

0.1.0.0 http://github.com/gigorok/php-orm

PHP ORM library

  Sources   Download

MIT

The Requires

 

The Development Requires