2017 © Pedro Peláez
 

library phpred

Relationships, Entities and Datasources for PHP

image

mcred/phpred

Relationships, Entities and Datasources for PHP

  • Thursday, August 31, 2017
  • by mcred
  • Repository
  • 1 Watchers
  • 0 Stars
  • 70 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

PHPRed

Build Status Code Climate Test Coverage Issue Count, (*1)

Description

PHPRed is an opinionated light weight ORM. While there are many available ORMs for PHP, many contain features that I have never used. PHPRed contains very basic methods and usage., (*2)

Requirements

  • PHP 7.1+
  • Composer
  • Mysqli

Installation

composer require mcred/phpred

Setup

In addition to the example below, there are examples available in the `tests/mocks` folder. Setting up a model is very easy: create a model class that extends the `PHPRed/Models/Model` class then define the properties of that model in the constructor. Such as: , (*3)

<?php
class MyClass extends \PHPRed\Models\Model
{
    public function __construct(\MysqliDb $mysql)
    {
        $this->model = 'MyClass';
        $this->table = 'my_class';
        $this->primaryKey = 'id';
        $this->foreignKey = 'my_class_id';
        $this->fields = ['id', 'name'];
        $this->requiredFields = ['name'];
        $this->uniqueFields = ['name'];
        $this->hasMany = ['MyClassProperties'];
        $this->hasAndBelongsToMany = ['Users'];

        parent::__construct($mysql);
    }
}

Constructor Properties

  • model: string
  • table: string
  • primaryKey: string
  • foreignKey: string
  • fields: array
  • requiredFields: array
  • uniqueFields: array
  • hasMany: array
  • belongsTo: array
  • hasAndBelongsToMany: array

Methods

  • getAll() : array
  • getById(int $modelId) : array
  • getBySearch(array ['key' => 'value']) : array
  • insert(array $data) : array
  • updateById(int $modelId, array $data) : array
  • deleteById(int $modelId): void

The Versions

31/08 2017

dev-master

9999999-dev

Relationships, Entities and Datasources for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Derek Smart
by Derek Smart

31/08 2017

0.0.5

0.0.5.0

Relationships, Entities and Datasources for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Derek Smart

31/08 2017

0.0.4

0.0.4.0

Relationships, Entities and Datasources for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Derek Smart

30/08 2017

0.0.3

0.0.3.0

Relationships, Entities and Datasources for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Derek Smart