voku/paris

This package is abandoned and no longer maintained. The author suggests using the j4mie/paris package instead.

A lightweight Active Record implementation for PHP5, built on top of Idiorm

v1.7.6 2017-08-10 19:52 UTC

README

Build Status codecov.io Codacy Badge SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version PHP 7 ready License

Paris

http://j4mie.github.com/idiormandparis/

WARNING: this is only a Maintained-Fork from: "https://github.com/j4mie/paris/"

INFO: you can use my Simple Active Record lib instad of Paris: "https://github.com/voku/simple-active-record"

Installation

The recommended installation way is through Composer.

$ composer require voku/paris

A lightweight Active Record implementation for PHP5.

Built on top of Idiorm.

Tested on PHP 5.3+ - may work on earlier versions with PDO and the correct database drivers.

Released under a BSD license.

Features

  • Extremely simple configuration.
  • Exposes the full power of Idiorm's fluent query API.
  • Supports associations.
  • Simple mechanism to encapsulate common queries in filter methods.
  • Built on top of PDO.
  • Uses prepared statements throughout to protect against SQL injection attacks.
  • Database agnostic. Currently supports SQLite, MySQL, Firebird and PostgreSQL. May support others, please give it a try!
  • Supports collections of models with method chaining to filter or apply actions to multiple results at once.
  • Multiple connections are supported

Documentation

The documentation is hosted on Read the Docs: paris.rtfd.org

Building the Docs

You will need to install Sphinx and then in the docs folder run:

make html

The documentation will now be in docs/_build/html/index.html

Let's See Some Code

/**
 * User: a sample user-class
 *
 * @property-read int    $id
 * @property-read string $first_name
 */
class User extends Model {
  public function tweets() {
      return $this->has_many('Tweet');
  }
  
  public function getId()
  {
    return $this->id;
  }
    
  public function getFirstName()
  {
    return $this->first_name
  }
}

/**
 * Tweet: a sample twitter-class
 *
 * @property-read int    $id
 * @property-read string $text
 */
class Tweet extends Model {
  
}

$user = Model::factory('User')
  ->where_equal('username', 'j4mie')
    ->find_one();
$user->first_name = 'Jamie';
$user->save();

$tweets = $user->tweets()->find_many();
foreach ($tweets as $tweet) {
  echo $tweet->text;
}