CRUD is a abstraction of PDO for simplify to simplify reading, writing, updating and removing data from the Database

1.0.5 2023-09-03 15:15 UTC

This package is auto-updated.

Last update: 2024-02-03 16:11:06 UTC


README

Maintainer Source Code PHP from Packagist Latest Version Software License Build Quality Score Total Downloads

CRUD is a abstraction of PDO to simplify reading, writing, updating and removing data from the Database.

CRUD é uma abstração para simplificar a leitura, escrita, atualização e remoção de dados do Banco de Dados.

Highlights

  • Extremaly Easy
  • Executa Leitura, Escrita e remoção de dados no Banco de dados
  • Trabalha com variáveis de Ambiente para setar as configurações do Banco de dados
  • Composer ready and PSR-2 compliant (Pronto para o Composer e compatível com PSR-2)
BEFORE INSTALL!

For you work with this component, is important work with a component like bash vlucas/dotenv for you set your enviroment variables;

DB_DRIVER="mysql"
DB_PORT="3306"
DB_HOST="your_database_host"
DB_USER="root"
DB_PASSWORD="passworddb"
DB_NAME="elephpant"

Installation

CRUD is available via Composer:

"elephpant/crud": "*"

or run

composer require elephpant/crud

Documentation

<?php

require __DIR__ . "/vendor/autoload.php";

use ElePHPant\CRUD;

/* QuickStart with CRUD class :: Call the class and set table from database that you'll use */
$crud = (new CRUD())::setTable("users");

/* Create  */
$arrayWithData = array(...);
$create = $crud->create($arrayWithData);

/* Reading Data :: For Default the read Method utilize the \stdClass like FETCH_CLASS, but ou can utilize other Concrete class for thar */
$read = $crud->read(stdClass::class, true);

/* Update */
$update = $crud->update($arrayWithData, "gender = 'male'");

/* Delete */
$delete = $crud->delete("id = :id", "id=1");

/* Setting Params with CRUD Class */
$params = "gender=male";
$crud->setParams($params);

/* DEBUGGING :: For you identify your Query*/
var_dump($crud->getQuery());

/* PDOException */
if (!$crud->create($arrayWithData)) {
    var_dump($crud->getFail());
}
?>

Contributing

Please see CONTRIBUTING for details.

Support

Security: If you discover any security related issues, please email sergiodanilojr@hotmail.com instead of using the issue tracker.

Se você descobrir algum problema relacionado à segurança, envie um e-mail para sergiodanilojr@hotmail.com em vez de usar o rastreador de problemas.

Thank you

Credits

License

The MIT License (MIT). Please see License File for more infcrudation.