Skip to content

bubu-framework/database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database library (bubu framework)

Installation with composer

$ composer require bubu-framework/database

Configuration

Follow .env.example syntaxe

Usage


Create table

Call Database CreateTable const for create table, setup him and call execute function for create the table. Call addColumn method for create a column and add to table.

  • Example:

    Database::createTable('test')->addColumn(
        Database::createColumn('col1')
        ->type(CreateColumn::INT)
        ->size(10)
        ->defaultValue(30)
        ->comments("It's ok")
        ->notNull()
        )
        ->addColumn(
            Database::createColumn('id')
                ->type(CreateColumn::INT)
                ->size(11)
                ->autoIncrement()
        )
        ->addIndex([
            'type' => 'primary',
            'columns' => ['id'],
            'name' => 'primaryKey'
        ])
        ->addIndex([
            'type' => CreateTable::UNIQUE_INDEX,
            'columns' => ['col1', 'id'],
            'name' => 'uniqueKey'
        ])
        ->execute();