codewdev/tablegenerator

Biblioteca de criação de tabelas para projetos em php

v1.0.0 2021-08-09 16:35 UTC

This package is auto-updated.

Last update: 2024-09-10 01:09:08 UTC


README

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

The table generator is a component for creating tables for your database that uses PDO to add, delete and edit tables using a flat file in php.

O table generator é um componente para criação de tabelas para seu banco de dados que usa PDO para incluir, deletar e editar tabelas usando m arquivo simples em php.

Highlights

  • Easy to set up (Fácil de configurar)
  • Create tables fast and easy (Crie tabelas rápido e fácil)
  • Composer ready (Pronto para o composer)

Installation

Table Generator is available via Composer:

"codewdev/tablegenerator": "1.0.*"

or run

composer require codewdev/tablegenerator

Documentation

For more details on how to use Table Generator, see the example folder with details in the component directory

Para mais detalhes sobre como usar o Table Generator, veja a pasta de exemplo com detalhes no diretório do componente

connection

To begin using the Table Generator, you need to connect to the database (MariaDB / MySql). For more connections PDO connections manual on PHP.net

Para começar a usar o Table Generator precisamos de uma conexão com o seu banco de dados. Para ver as conexões possíveis acesse o manual de conexões do PDO em PHP.net

define("TABLE_GEN_CONF", [
    "driver" => "mysql",
    "host" => "localhost",
    "port" => "3306",
    "dbname" => "nome_db",
    "username" => "root",
    "passwd" => "",
    "options" => [
        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
        PDO::ATTR_CASE => PDO::CASE_NATURAL
    ]
]);

your model

<?php

use CodeWdev\TableGenerator\TableGenerator;

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


//creating table
$user_data = new TableGenerator("users", [
    "first_name" => "VARCHAR(10) NOT NULL",
    "last_name" => "VARCHAR(255) NOT NULL",
    "email" => "VARCHAR(255) UNIQUE NOT NULL",
    "password" => "VARCHAR(255) NOT NULL DEFAULT 0"
]);


//command to create the table
$user_data->create();


//adding columns to the table
$user_data->addColumn([
    "document" => "VARCHAR(10)",
    "company" => "VARCHAR(50) NOT NULL"
]);


//
//deleting a column
$user_data->dropColumn("company");


//deleting a table
$user_data->drop();

Contributing

Please see CONTRIBUTING for details.

Support

If you discover any issues related to the component or would like to make a contribution, please feel free to get in touch.

Se você descobrir algum problema relacionado ao componente ou quiser dar uma contribuição, fique a vontade para entrar em contato.

Thank you

Credits

License

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