PHP Classes
elePHPant
Icontem

PHP Expressive: Base class for Object Relational Mapping

Recommend this page to a friend!
  Info   View files Documentation   View files View files (70)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-08-31 (20 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 47 This week: 10All time: 8,969 This week: 56Up
Version License PHP version Categories
php-expressive 1.0.0The PHP License7Databases, Design Patterns, PHP 7
Description Author

This package provides a base class for Object Relational Mapping.

The base class provide basic ORM operations and should be extended by actual entity classes that define the properties to be saved to a database.

The package also provides a trait to map magic methods to access property values.

Name: Rafael Becker <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: ???
All time rank: 4118337 in Brazil Brazil
Week rank: 57 Up2 in Brazil Brazil Up

Details

README

Expressive

Expressive é uma biblioteca para mapeamento objeto relacional construída sobre o illuminate/database illuminate/database, com definições de objetos baseada em arquivos de schema.

Install

Esse pacote foi estruturado para ser instalado por meio do composer.

composer require solis/expressive

Usage

Defina a estrutura de um objeto de acordo com as especificações do phpschema.

{
  "database": {
    "repository": "tbproduto",
    "keys": [
      "empcodigo",
      "procodigo"
    ]
  },
  "properties": [
    {
      "alias": "iEmpCodigo",
      "property": "empcodigo",
      "type": "int"
    },
    {
      "alias": "iCodigo",
      "property": "procodigo",
      "type": "int",
      "behavior": {
        "autoIncrement": "true",
        "incrementalBehavior": "application"
      }
    },
    {
      "alias": "sDescricao",
      "property": "prodescricao",
      "type": "string"
    },
    {
      "alias": "iGicCodigo",
      "property": "giccodigo",
      "type": "int"
    },
    {
      "alias": "iGpcCodigo",
      "property": "gpccodigo",
      "type": "int"
    }
  ]
}

Uma Classe que utiliza a funcionalidade ORM fornecida pela biblioteca deve extender a class abstrata Expressive e ter em si declaradas as propriedades especificadas no schema json.

use Solis\Expressive\Classes\Illuminate\Expressive;
use Solis\Expressive\Magic\Concerns\HasMagic;

/
 * Class Cst
 *
 * @package Sample\Postgres\Cst\Classes
 */
class Cst extends Expressive
{    
    use HasMagic;
    
    protected $empcodigo;
    protected $procodigo;
    protected $prodescricao;
    protected $giccodigo;
    protected $gpccodigo;
    protected $cstipicodigo;    

    /
     * Produto constructor.
     */
    public function __construct()
    {
        parent::__construct();

        $this->start(dirname(__FILE__) . '/Produto.json');
    }
}     

O método start é responsável por construir um objeto Schema a partir do caminho fornecido e atribuir a respectiva classe.

Uma classe extendo Expressive deve utilizar a trait HasMagic de modo ater acesso a funcionalidade de atribuição dinâmica por meio do método make.

$Produto = Produto::make(
    [
        "procodigo"     => 1,
        "empcodigo"     => 264,
        "iGicCodigo"    => 1,
        "iGpcCodigo"    => 1,
        "prodescricao"  => 'test [ ' . uniqid(rand()) . ' ]',        
    ]
);

O método make retorna uma instância de ExpressiveAbstract com acesso as operações de persistência disponibilizadas pela biblioteca.

Operations

Relação de operações de persistência que podem ser utilizadas por uma instância de ExpressiveAbstract

Count

Retorna um valor inteiro representando a contagem de registros na persistência.

(new Produto())->count(
    [
        [
            "column" => "empcodigo",
            "value"  => 264
        ]
    ]
)

Create

Cria um novo registro na persistência de acordo com os valores fornecidos para construção do objeto por meio do make.

$Produto = Produto::make(
    [
        "procodigo"     => 1,
        "empcodigo"     => 264,
        "iGicCodigo"    => 1,
        "iGpcCodigo"    => 1,
        "prodescricao"  => 'test [ ' . uniqid(rand()) . ' ]'
    ]
)->create();

Delete

Deleta um registro na persistência de acordo com as informações atribuidas ao active record.

Produto::make(
    [
        'empcodigo' => 264,
        'procodigo' => 1
    ]
)->search()->delete();

Last

Retorna o último registro na persistencia de acordo com as informações atribuidas ao active record.

Produto::make([
    'empcodigo' => 264
])->last()

Replicate

Replica um registro existente na persistência de acordo com as informações atribuidas ao active record.

$instance = Produto::make([
    'iEmpCodigo' => 263,
])->last();

$instance->replicate();    

Search

Retorna um registro existente na persistência de acordo com as informações atribuidas ao active record.

$instance = Produto::make([
    'procodigo' => 1,
    'empcodigo' => 264,
])->search();

Select

Retorna uma relação de registros existentes na persistência de acordo a relação de argumentos e opções fornecidas.

$result = (new Produto())
    ->select();

Update

Atualiza um registro existente na persistência de acordo com as informações atribuidas ao active record.

$instance = Produto::make(
    [
        'empcodigo' => 264,
        'procodigo' => 67,
    ]
)->search();

$instance->prodescricao = 'EMP 264 UPDATE TEST [ ' . Date('Y-m-d H:m:s') . ']';
$instance->giccodigo = 2;

$instance->update();

Change log

Acompanhe o CHANGELOG para informações sobre atualizações recentes.

Testing

(Em desenvolvimento)

$ composer test

License

The MIT License (MIT). Verifique LICENSE para mais informações.

  Files folder image Files  
File Role Description
Files folder imageapp (1 directory)
Files folder imagesample (5 directories)
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file Dockerfile Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file README.MD Doc. Documentation
Accessible without login Plain text file site.conf Data Auxiliary data
Accessible without login Plain text file start.sh Data Auxiliary data

  Files folder image Files  /  app  
File Role Description
Files folder imagesrc (3 directories)

  Files folder image Files  /  app  /  src  
File Role Description
Files folder imageAbstractions (2 files)
Files folder imageClasses (1 directory)
Files folder imageContracts (2 files)

  Files folder image Files  /  app  /  src  /  Abstractions  
File Role Description
  Plain text file DatabaseContainerAbstract.php Class Class source
  Plain text file ExpressiveAbstract.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  
File Role Description
Files folder imageIlluminate (4 files, 7 directories)

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  
File Role Description
Files folder imageDelete (2 files)
Files folder imageInsert (2 files)
Files folder imagePatch (2 files)
Files folder imageReplicate (1 file)
Files folder imageSelect (2 files)
Files folder imageUpdate (2 files)
Files folder imageUtil (1 file)
  Plain text file Database.php Class Class source
  Plain text file Diglett.php Class Class source
  Plain text file Expressive.php Class Class source
  Plain text file Wrapper.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Delete  
File Role Description
  Plain text file DeleteBuilder.php Class Class source
  Plain text file RelationshipBuilder.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Insert  
File Role Description
  Plain text file InsertBuilder.php Class Class source
  Plain text file RelationshipBuilder.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Patch  
File Role Description
  Plain text file PatchBuilder.php Class Class source
  Plain text file RelationshipBuilder.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Replicate  
File Role Description
  Plain text file ReplicateBuilder.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Select  
File Role Description
  Plain text file RelationshipBuilder.php Class Class source
  Plain text file SelectBuilder.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Update  
File Role Description
  Plain text file RelationshipBuilder.php Class Class source
  Plain text file UpdateBuilder.php Class Class source

  Files folder image Files  /  app  /  src  /  Classes  /  Illuminate  /  Util  
File Role Description
  Plain text file Actions.php Class Class source

  Files folder image Files  /  app  /  src  /  Contracts  
File Role Description
  Plain text file DatabaseContainerContract.php Class Class source
  Plain text file ExpressiveContract.php Class Class source

  Files folder image Files  /  sample  
File Role Description
Files folder imageCst (10 directories)
Files folder imageDatabase (1 file)
Files folder imageEmpresa (4 directories)
Files folder imageNFe (8 directories)
Files folder imageProduto (10 directories)

  Files folder image Files  /  sample  /  Cst  
File Role Description
Files folder imageClasses (3 files)
Files folder imagecount (1 file)
Files folder imagecreate (1 file)
Files folder imagedelete (1 file)
Files folder imagelast (1 file)
Files folder imagepatch (1 file)
Files folder imagereplicate (1 file)
Files folder imagesearch (1 file)
Files folder imageselect (1 file)
Files folder imageupdate (1 file)

  Files folder image Files  /  sample  /  Cst  /  Classes  
File Role Description
  Accessible without login Plain text file Cst.json Data Auxiliary data
  Plain text file Cst.php Class Class source
  Plain text file Helper.php Class Class source

  Files folder image Files  /  sample  /  Cst  /  count  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  create  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  delete  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  last  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  patch  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  replicate  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  search  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  select  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Cst  /  update  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Database  
File Role Description
  Accessible without login Plain text file config.php Aux. Auxiliary script

  Files folder image Files  /  sample  /  Empresa  
File Role Description
Files folder imageClasses (2 files)
Files folder imagecount (1 file)
Files folder imagesearch (1 file)
Files folder imageselect (2 files)

  Files folder image Files  /  sample  /  Empresa  /  Classes  
File Role Description
  Accessible without login Plain text file Empresa.json Data Auxiliary data
  Plain text file Empresa.php Class Class source

  Files folder image Files  /  sample  /  Empresa  /  count  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Empresa  /  search  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Empresa  /  select  
File Role Description
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file timer.php Example Example script

  Files folder image Files  /  sample  /  NFe  
File Role Description
Files folder imageClasses (4 files)
Files folder imagecreate (2 files)
Files folder imagedelete (1 file)
Files folder imagelast (1 file)
Files folder imagepatch (1 file)
Files folder imagereplicate (1 file)
Files folder imagesearch (1 file)
Files folder imageselect (1 file)

  Files folder image Files  /  sample  /  NFe  /  Classes  
File Role Description
  Accessible without login Plain text file NFe.json Data Auxiliary data
  Plain text file NFe.php Class Class source
  Accessible without login Plain text file NFeItem.json Data Auxiliary data
  Plain text file NFeItem.php Class Class source

  Files folder image Files  /  sample  /  NFe  /  create  
File Role Description
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file timer.php Example Example script

  Files folder image Files  /  sample  /  NFe  /  delete  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  NFe  /  last  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  NFe  /  patch  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  NFe  /  replicate  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  NFe  /  search  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  NFe  /  select  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  
File Role Description
Files folder imageClasses (2 files)
Files folder imagecount (1 file)
Files folder imagecreate (1 file)
Files folder imagedelete (1 file)
Files folder imagelast (1 file)
Files folder imagepatch (1 file)
Files folder imagereplicate (1 file)
Files folder imagesearch (1 file)
Files folder imageselect (1 file)
Files folder imageupdate (1 file)

  Files folder image Files  /  sample  /  Produto  /  Classes  
File Role Description
  Accessible without login Plain text file Produto.json Data Auxiliary data
  Plain text file Produto.php Class Class source

  Files folder image Files  /  sample  /  Produto  /  count  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  create  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  delete  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  last  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  patch  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  replicate  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  search  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  select  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  sample  /  Produto  /  update  
File Role Description
  Accessible without login Plain text file index.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:47
This week:10
All time:8,969
This week:56Up