PHP code example of gsferro / database-schema-easy
1. Go to this page and download the library: Download gsferro/database-schema-easy library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gsferro / database-schema-easy example snippets
$schema->hasTable();
# true
$schema->getColumnListing();
/*
[
"id",
"uuid",
"pedido_status_id",
]
*/
$schema->hasColumns(['id', 'uuid']);
# true
$schema->hasColumnsTimestamps();
# true
$schema->getTypeFromColumns(['id', 'uuid']);
/*
[
"id" => "integer",
"uuid" => "guid",
]
*/
$schema->getColumnType('id');
# "integer"
$schema->getDoctrineColumn('id');
/*
[
"name" => "id",
"type" => Doctrine\DBAL\Types\IntegerType {#4751},
"default" => null,
"notnull" => true,
"length" => null,
"precision" => 10,
"scale" => 0,
"fixed" => false,
"unsigned" => false,
"autoincrement" => true,
"columnDefinition" => null,
"comment" => null,
"primary_key" => true,
]
*/
$schema->isPrimaryKey('id');
# true
$schema->primaryKeys();
/*
[
"id",
]
*/
$schema->hasModelWithTableName();
# "App\Models\Pedidos"
$schema->hasModelWithTableName('abc');
# false
$schema->getAllTables();
/*
[
'pedidos',
'pedido_status,
...
]
*/
$schema->hasForeinsKey('pedido_status_id');
/*
[
"table" => "pedido_status",
"tableCamel" => Illuminate\Support\Stringable {#5069
value: "pedidoStatus",
},
"related" => Illuminate\Support\Stringable {#5068
value: "",
},
"relatedInstance" => false,
"foreignKey" => "pedido_status_id",
"ownerKey" => "id",
]
*/