Download the PHP package fyre/forge without Composer
On this page you can find all versions of the php package fyre/forge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package forge
FyreForge
FyreForge is a free, open-source database forge library for PHP.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Forges
- MySQL Forges
- Postgres Forges
- Sqlite Forges
- Table
- MySQL Tables
- Postgres Tables
- Sqlite Tables
- Columns
- MySQL Columns
- Indexes
- Foreign Keys
Installation
Using Composer
In PHP:
Basic Usage
$containeris a Container.
Autoloading
It is recommended to bind the ForgeRegistry to the Container as a singleton.
Any dependencies will be injected automatically when loading from the Container.
Methods
Map
Map a Connection class to a Forge handler.
$connectionClassis a string representing the Connection class name.$forgeClassis a string representing the Forge class name.
Use
Load the shared Connection.
$connectionis a Connection.
Container.
Forges
Add Column
Add a column to a table.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.nullableis a boolean indicating whether the column is nullable, and will default to false.defaultis a string representing the column default value, and will default to null (no default).autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Additional column options may be available depending on the connection handler.
Add Foreign Key
Add a foreign key to a table.
$tableNameis a string representing the table name.$foreignKeyNameis a string representing the foreign key name.$optionsis an array containing the foreign key options.columnsis a string or array containing the columns to use for the foreign key, and will default to the foreign key name.referencedTableis a string representing the referenced table to use.referencedColumnsis a string or array containing the columns to use in the referenced table.onUpdateis a string containing the ON UPDATE operation, and will default to null.onDeleteis a string containing the ON DELETE operation, and will default to null.
Foreign keys cannot be added to an existing Sqlite table.
Add Index
Add an index to a table.
$tableNameis a string representing the table name.$indexNameis a string representing the index name.$optionsis an array containing the index options.columnsis a string or array containing the columns to use for the index, and will default to the index name.uniqueis a boolean indicating whether the index must be unique, and will default to false.primaryis a boolean indicating whether the index is a primary key, and will default to false.
Additional index options may be available depending on the connection handler.
Primary keys cannot be added to an existing Sqlite table.
Alter Table
Alter a table.
$tableNameis a string representing the table name.$optionsis an array containing the table options.
Additional table options may be available depending on the connection handler.
Build
Build a Table.
$tableNameis a string representing the table name.$optionsis an array containing the table options.
Table dependencies will be resolved automatically from the Container.
Additional table options may be available depending on the connection handler.
Create Table
Create a new table.
$tableNameis a string representing the table name.$columnsis an array containing the column definitions.$indexesis an array containing the index definitions.$foreignKeysis an array containing the foreign key definitions.$optionsis an array containing the schema options.
Additional table options may be available depending on the connection handler.
Drop Column
Drop a column from a table.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.
Drop Foreign Key
Drop a foreign key from a table.
$tableNameis a string representing the table name.$foreignKeyNameis a string representing the foreign key name.
Foreign keys cannot be dropped from an existing Sqlite table.
Drop Index
Drop an index from a table.
$tableNameis a string representing the table name.$indexNameis a string representing the index name.
Primary keys cannot be dropped from an existing Sqlite table.
Drop Table
Drop a table.
$tableNameis a string representing the table name.
Get Connection
Get the Connection.
Rename Column
Rename a column.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$newColumnNameis a string representing the new column name.
Rename Table
Rename a table.
$tableNameis a string representing the table name.$newTableNameis a string representing the new table name.
MySQL Forges
The MySQL Forge extends the Forge class and provides additional methods and options specific to MySQL databases.
Add Column
Add a column to a table.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.valuesis an array containing the enum/set values, and will default to null.nullableis a boolean indicating whether the column is nullable, and will default to false.unsignedis a boolean indicating whether the column is unsigned, and will default to false.defaultis a string representing the column default value, and will default to null (no default).charsetis a string representing the column character set, and will default to the connection character set.collationis a string representing the column collation, and will default to the connection collation.autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.commentis a string representing the column comment, and will default to "".afteris a string representing the column to add this column after, and will default to null.firstis a boolean indicating whether to add this column first in the table, and will default to false.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Add Index
Add an index to a table.
$tableNameis a string representing the table name.$indexNameis a string representing the index name.$optionsis an array containing the index options.columnsis a string or array containing the columns to use for the index, and will default to the index name.typeis a string representing the index type, and will default to "BTREE".uniqueis a boolean indicating whether the index must be unique, and will default to false.primaryis a boolean indicating whether the index is a primary key, and will default to false.
Alter Table
Alter a table.
$tableNameis a string representing the table name.$optionsis an array containing the table options.engineis a string representing the table engine, and will default to "InnoDB".charsetis a string representing the table character set, and will default to the connection character set.collationis a string representing the table collation, and will default to the connection collation.commentis a string representing the table comment, and will default to "".
Build
Build a Table.
$tableNameis a string representing the table name.$optionsis an array containing the table options.engineis a string representing the table engine, and will default to "InnoDB".charsetis a string representing the table character set, and will default to the connection character set.collationis a string representing the table collation, and will default to the connection collation.commentis a string representing the table comment, and will default to "".
Table dependencies will be resolved automatically from the Container.
Change Column
Change a table column.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$optionsis an array containing the column options.nameis a string representing the new column name.typeis a string representing the column type.lengthis a number representing the column length.precisionis a number representing the column precision.valuesis an array containing the enum/set values.nullableis a boolean indicating whether the column is nullable.unsignedis a boolean indicating whether the column is unsigned.defaultis a string representing the column default value.charsetis a string representing the column character set.collationis a string representing the column collation.autoIncrementis a boolean indicating whether the column is an an auto incrementing column.commentis a string representing the column comment.afteris a string representing the column to add this column after.firstis a boolean indicating whether to add this column first in the table.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Unspecified options will default to the current value.
Create Schema
Create a new schema.
$schemais a string representing the schema name.$optionsis an array containing the schema options.charsetis a string representing the schema character set, and will default to the connection character set.collationis a string representing the schema collation, and will default to the connection collation.ifNotExistsis a boolean indicating whether to use anIF NOT EXISTSclause, and will default to false.
Create Table
Create a new table.
$tableis a string representing the table name.$columnsis an array containing the column definitions.$indexesis an array containing the index definitions.$foreignKeysis an array containing the foreign key definitions.$optionsis an array containing the schema options.engineis a string representing the table engine, and will default to "InnoDB".charsetis a string representing the table character set, and will default to the connection character set.collationis a string representing the table collation, and will default to the connection collation.commentis a string representing the table comment, and will default to "".
Drop Primary Key
Drop a primary key from a table.
$tableNameis a string representing the table name.
Drop Schema
Drop a schema.
$schemais a string representing the schema name.$optionsis an array containing the schema options.ifExistsis a boolean indicating whether to use anIF EXISTSclause, and will default to false.
Postgres
The Postgres Forge extends the Forge class and provides additional methods and options specific to Postgres databases.
Add Column
Add a column to a table.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.nullableis a boolean indicating whether the column is nullable, and will default to false.defaultis a string representing the column default value, and will default to null (no default).autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.commentis a string representing the column comment, and will default to "".
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Alter Table
Alter a table.
$tableNameis a string representing the table name.$optionsis an array containing the table options.commentis a string representing the table comment, and will default to "".
Build
Build a Table.
$tableNameis a string representing the table name.$optionsis an array containing the table options.commentis a string representing the table comment, and will default to "".
Table dependencies will be resolved automatically from the Container.
Change Column
Change a table column.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$optionsis an array containing the column options.nameis a string representing the new column name.typeis a string representing the column type.lengthis a number representing the column length.precisionis a number representing the column precision.nullableis a boolean indicating whether the column is nullable.defaultis a string representing the column default value.autoIncrementis a boolean indicating whether the column is an an auto incrementing column.commentis a string representing the column comment.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Unspecified options will default to the current value.
Create Schema
Create a new schema.
$schemais a string representing the schema name.$optionsis an array containing the schema options.ifNotExistsis a boolean indicating whether to use anIF NOT EXISTSclause, and will default to false.
Create Table
Create a new table.
$tableis a string representing the table name.$columnsis an array containing the column definitions.$indexesis an array containing the index definitions.$foreignKeysis an array containing the foreign key definitions.$optionsis an array containing the schema options.commentis a string representing the table comment, and will default to "".
Drop Primary Key
Drop a primary key from a table.
$tableNameis a string representing the table name.
Drop Schema
Drop a schema.
$schemais a string representing the schema name.$optionsis an array containing the schema options.ifExistsis a boolean indicating whether to use anIF EXISTSclause, and will default to false.
Sqlite
The Sqlite Forge extends the Forge class.
Add Column
Add a column to a table.
$tableNameis a string representing the table name.$columnNameis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.nullableis a boolean indicating whether the column is nullable, and will default to false.unsignedis a boolean indicating whether the column is unsigned, and will default to false.defaultis a string representing the column default value, and will default to null (no default).autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Tables
Add Column
Add a column to the table.
$columnis a string representing the column name.$optionsis an array containing the column options.nameis a string representing the new column name, and will default to the column name.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.nullableis a boolean indicating whether the column is nullable, and will default to false.defaultis a string representing the column default value, and will default to null (no default).autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Additional column options may be available depending on the connection handler.
Add Foreign Key
Add a foreign key to the table.
$foreignKeyis a string representing the foreign key name.$optionsis an array containing the foreign key options.columnsis a string or array containing the columns to use for the foreign key, and will default to the foreign key name.referencedTableis a string representing the referenced table to use.referencedColumnsis a string or array containing the columns to use in the referenced table.onUpdateis a string containing the ON UPDATE operation, and will default to null.onDeleteis a string containing the ON DELETE operation, and will default to null.
Foreign keys cannot be added to an existing Sqlite table.
Add Index
Add an index to the table.
$indexis a string representing the index name.$optionsis an array containing the index options.columnsis a string or array containing the columns to use for the index, and will default to the index name.uniqueis a boolean indicating whether the index must be unique, and will default to false.primaryis a boolean indicating whether the index is a primary key, and will default to false.
Additional index options may be available depending on the connection handler.
Primary keys cannot be added to an existing Sqlite table.
Change Column
Change a table column.
$columnis a string representing the column name.$optionsis an array containing the column options.nameis a string representing the new column name, and will default to the column name.
Additional column options may be available depending on the connection handler.
Column definitions can not be modified for an existing Sqlite table.
Clear
Clear the column and index data.
Column
Get a Column.
$nameis a string representing the column name.
Column Names
Get the names of all table columns.
Columns
Get all table columns.
Drop
Drop the table.
Drop Column
Drop a column from the table.
$columnis a string representing the column name.
Drop Foreign Key
Drop a foreign key from the table.
$foreignKeyis a string representing the foreign key name.
Foreign keys cannot be dropped from an existing Sqlite table.
Drop Index
Drop an index from the table.
$indexis a string representing the index name.
Primary keys cannot be dropped from an existing Sqlite table.
Execute
Generate and execute the SQL queries.
Foreign Key
Get a table ForeignKey.
$nameis a string representing the foreign key name.
Foreign Keys
Get all table foreign keys.
Get Comment
Get the table comment.
Get Forge
Get the Forge.
Get Name
Get the table name.
Has Column
Determine whether the table has a column.
$nameis a string representing the column name.
Has Foreign Key
Determine whether the table has a foreign key.
$nameis a string representing the foreign key name.
Has Index
Determine whether the table has an index.
$nameis a string representing the index name.
Index
Get a table Index.
$nameis a string representing the index name.
Indexes
Get all table indexes.
Rename
Rename the table.
$tableis a string representing the new table name.
Set Primary Key
Set the primary key.
$columnsis a string or array containing the columns to use for the primary key.
Primary keys cannot be added to an existing Sqlite table.
SQL
Generate the SQL queries.
To Array
Get the table data as an array.
MySQL Tables
Add Column
Add a column to the table.
$columnis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.valuesis an array containing the enum/set values, and will default to null.nullableis a boolean indicating whether the column is nullable, and will default to false.unsignedis a boolean indicating whether the column is unsigned, and will default to false.defaultis a string representing the column default value, and will default to null (no default).charsetis a string representing the column character set, and will default to the connection character set.collationis a string representing the column collation, and will default to the connection collation.autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.commentis a string representing the column comment, and will default to "".afteris a string representing the column to add this column after, and will default to null.firstis a boolean indicating whether to add this column first in the table, and will default to false.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Add Index
Add an index to the table.
$indexis a string representing the index name.$optionsis an array containing the index options.columnsis a string or array containing the columns to use for the index, and will default to the index name.typeis a string representing the index type, and will default to "BTREE".uniqueis a boolean indicating whether the index must be unique, and will default to false.primaryis a boolean indicating whether the index is a primary key, and will default to false.
Change Column
Change a table column.
$columnis a string representing the column name.$optionsis an array containing the column options.nameis a string representing the new column name.typeis a string representing the column type.lengthis a number representing the column length.precisionis a number representing the column precision.valuesis an array containing the enum/set values.nullableis a boolean indicating whether the column is nullable.unsignedis a boolean indicating whether the column is unsigned.defaultis a string representing the column default value.charsetis a string representing the column character set.collationis a string representing the column collation.autoIncrementis a boolean indicating whether the column is an an auto incrementing column.commentis a string representing the column comment.afteris a string representing the column to add this column after.firstis a boolean indicating whether to add this column first in the table.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Unspecified options will default to the current value.
Get Charset
Get the table character set.
Get Collation
Get the table collation.
Get Engine
Get the table engine.
Postgres Tables
Add Column
Add a column to the table.
$columnis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.nullableis a boolean indicating whether the column is nullable, and will default to false.defaultis a string representing the column default value, and will default to null (no default).autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.commentis a string representing the column comment, and will default to "".
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Add Index
Add an index to the table.
$indexis a string representing the index name.$optionsis an array containing the index options.columnsis a string or array containing the columns to use for the index, and will default to the index name.typeis a string representing the index type, and will default to "BTREE".uniqueis a boolean indicating whether the index must be unique, and will default to false.primaryis a boolean indicating whether the index is a primary key, and will default to false.
Change Column
Change a table column.
$columnis a string representing the column name.$optionsis an array containing the column options.nameis a string representing the new column name.typeis a string representing the column type.lengthis a number representing the column length.precisionis a number representing the column precision.nullableis a boolean indicating whether the column is nullable.defaultis a string representing the column default value.autoIncrementis a boolean indicating whether the column is an an auto incrementing column.commentis a string representing the column comment.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Unspecified options will default to the current value.
Sqlite Tables
Add Column
Add a column to the table.
$columnis a string representing the column name.$optionsis an array containing the column options.typeis a string representing the column type, and will default toStringType::class.lengthis a number representing the column length, and will default to the type default.precisionis a number representing the column precision, and will default to the type default.nullableis a boolean indicating whether the column is nullable, and will default to false.unsignedis a boolean indicating whether the column is unsigned, and will default to false.defaultis a string representing the column default value, and will default to null (no default).autoIncrementis a boolean indicating whether the column is an an auto incrementing column, and will default to false.
You can also specify a Type class name as the type, which will be automatically mapped to the correct type.
Columns
Get Comment
Get the column comment.
Get Default
Get the column default value.
Get Length
Get the column length.
Get Name
Get the column name.
Get Precision
Get the column precision.
Get Table
Get the Table.
Get Type
Get the column type.
Is Auto Increment
Determine whether the column is an auto increment column.
Is Nullable
Determine whether the column is nullable.
Is Unsigned
Determine whether the column is unsigned.
To Array
Get the column data as an array.
MySQL Columns
Get Charset
Get the column character set.
Get Collation
Get the column collation.
Get Values
Get the column enum values.
Indexes
Get Columns
Get the column names.
Get Name
Get the index name.
Get Table
Get the Table.
Get Type
Get the index type.
Is Primary
Determine whether the index is primary.
Is Unique
Determine whether the index is unique.
To Array
Get the index data as an array.
Foreign Keys
Get Columns
Get the column names.
Get Name
Get On Delete
Get the delete action.
Get On Update
Get the update action.
Get Referenced Columns
Get the referenced column names.
Get Referenced Table
Get the referenced table name.
Get Table
Get the Table.
To Array
Get the foreign key data as an array.