Database Forge Library



( ZN >= 0.0.1

This library is a library developed on the creation, editing and deletion of databases, tables and columns. The DBForge :: library makes these operations very simple. Here's how to use the methods in this library individually.

 

 

# Methods


Bool createDatabase ( String $ dbname , Mixed $ extras = NULL )
Bool dropDatabase ( String $ dbname )
Bool createTable ( String $ table , Array $ condition , Mixed $ extras = NULL )
Bool dropTable ( String $ table )
Bool alterTable ( String $ table , Array $ condition )
Bool renameTable ( String $ name , String $ newName )
Bool addColumn ( String $ table , Array $ columns )
Bool dropColumn ( String $ table , Mixed $ column )
Bool modifyColumn ( String $ table , Array $ columns )
Bool renameColumn ( String $ table , Array $ condition )
Bool truncate ( String $ table )

 

 

# CreateDatabase ( ZN> = 0.0.1 )


Used to create the database .

Parameters
String $ Dbname The name of the database.
Mixed $ extras CREATE DATABASE DatabaseName [EXTRAS]Used to edit the Extras section.
return Bool
uses
DBForge::createDatabase('ExampleDatabase');

You can also specify the language encoding when creating the database.

DBForge::createDatabase('ExampleDatabase', DB::encoding());

 

 

# DropDatabase ( ZN> = 0.0.1 )


Used to delete the database.

Parameters
String $ Dbname The name of the database.
return Bool
uses
DBForge::dropDatabase('ExampleDatabase');

 

 

# CreateTable ( ZN> = 0.0.1 )


Used to create a new table.

Parameters
String $ Table Table name.
Array $ conditions Column and its properties.
Mixed $ extras CREATE DATABASE DatabaseName [EXTRAS]Used to edit the Extras section.
return Bool
uses
DBForge::createTable('ExampleTable',
[
    'id'   => 'int(11) not null', 
    'name' => 'varchar(50) COLLATE utf8_unicode_ci NOT NULL' 
], DB::encoding());
Compatibility with Different Platforms

You can also create your table to fit in with other database platforms as follows.

DBForge::createTable('ExampleTable', 
[ 
    'id'   => [DB::int(11), DB::autoIncrement(), DB::primaryKey()], 
    'name' => [DB::varchar(50), DB::notNull(), DB::collate('utf8_unicode_ci')] 
], DB::encoding());
Optional Usage

It is also possible to do table creation as follows.

DBForge::column('id', [DB::int(11), DB::notNull(), DB::autoIncrement()])
       ->column('name', [DB::varchar(50), DB::notNull(), DB::collate('utf8_unicode_ci')])
       ->createTable('ExampleTable');

 

 

# DropTable ( ZN >= 0.0.1 )


Used to delete the table.

Parameters
String $ Table Table name.
return Bool
uses
DBForge::dropTable('ExampleTable');

 

 

# AlterTable ( ZN >= 0.0.1 )


Changing the table name is used to add or delete columns.

Parameters
String $ Table Table name.
Array $ conditions Column and its properties.
return Bool
uses

The different uses for the alterTable () method are shown below.

Change Table Name
DBForge::alterTable('ExampleTable', ['renameTable' => 'NewExampleTable']);
Inserting Columns
DBForge::alterTable('ExampleTable', ['addColumn' => 
[
    'phone' => [DB::varchar(18)]
]]);
Colon Clearing
DBForge::alterTable('ExampleTable', ['dropColumn' => 'phone']);
Organizing the Column
DBForge::alterTable('ExampleTable', ['modifyColumn' =>
[
    'phone' => [DB::varchar(15)]
]]);
Changing Column Name
DBForge::alterTable('ExampleTable', ['renameColumn' =>
[
    'phone' => ['mobile_phone', DB::varchar(15)]
]]);

 

 

# RenameTable ( ZN >= 0.0.1 )


An alternative to alter table method is to change the table name, which is developed as an alternative to alter table name.

Parameters

Parameters
String $ Table Table name.
String $ NewName The new name for the table.
return Bool
uses
DBForge::renameTable('OldTableName' , 'NewTableName');

 

 

# AddColumn ( ZN >= 0.0.1 )


It is a practical column addition method developed as an alternative to alter table method for adding columns to a table .

Parameters
String $ Table Table name.
Array $ conditions Column and its properties.
return Bool
uses
DBForge::addColumn('ExampleTable' , 
[
   'phone' => [DB::int(11), DB::notNull()]
]);
S tring Column Properties

Column information can also be entered in string type.

DBForge::addColumn('ExampleTable' , ['phone' => 'int(11) not null']);
Optional Usage

It is also possible to perform the column addition process as follows.

DBForge::column('id', [DB::int(11), DB::notNull(), DB::autoIncrement()])
       ->column('name', [DB::varchar(50), DB::notNull(), DB::collate('utf8_unicode_ci')])
       ->addColumn('ExampleTable');

 

 

# DropColumn ( ZN >= 0.0.1 )


Tablodan is a practical column deletion method developed as an alternative to alter table method for deleting columns.

Parameters
String $ Table Table name.
Mixed $ columns Column and its properties.
return Bool
uses
DBForge::dropColumn('ExampleTable', ['name' , 'phone']);
Unique Deletion

If a single column is deleted , it can be set by type.2. parametre string

DBForge::dropColumn('ExampleTable' , 'name'); 
Optional Usage

It is also possible to perform the column erase operation as follows.

DBForge::column('name')
       ->column('phone')
       ->dropColumn('ExampleTable');

 

 

# RenameColumn ( ZN >= 0.0.1 )


It is a practical column name replacement method developed as an alternative to the alter table method to change the column name.

Parameters
String $ Table Table name.
Array $ conditions Column and its properties.
return Bool
uses
DBForge::renameColumn('ExapleTable', ['phone mobile_phone' => [DB::int(), DB::notNull()]]);
Optional Usage
DBForge::column('phone', ['new_phone', DB::int(), DB::notNull()])
       ->column('name',  ['new_name', DB::char(10), DB::notNull()])
       ->renameColumn('ExampleTable');

 

 

# ModifyColumn ( ZN >= 0.0.1 )


It is a practical column update method developed as an alternative to the alter table method to update the table column information .

Parameters
String $ Table Table name.
Array $ conditions Column and its properties.
return Bool
uses
DBForge::modifyColumn('ExampleTable', ['phone' => [DB::int(), DB::notNull()]]); 

 

 

# Truncate ( ZN >= 0.0.1 )


Used to empty table contents.

Parameters
String $ Table Table name.
return Bool
uses
DBForge::truncate('ExampleTable');