PHP code example of sevens / consoler
1. Go to this page and download the library: Download sevens/consoler 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/ */
sevens / consoler example snippets
$schemaMap = new SchemaMap($config = [
'directory' => __DIR__.'/migration',
'migrator' => 'Migration.php',
'populator' => 'Population.php'
]);
return[
'apps' => [
#the referenced table must already exist and the name must be exact to avoid errors
#$type can be one of ['int','string'] on a foreign key column
'token' => $this->foreign_key($table='sessions_table', $column='session' $type='string'),
//$key can be one of ['unique','fulltext', '']
'name' => $this->string($max_length=125, $null=true, $key='fulltext'),
'pos' => $this->integer($max_length=10),
//in other to specify a maximum length, float should be used instead of a double
'account_balance' => $this->double(),
'ledger' => $this->float($max_length=16),
'is_verified' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ),
'created_at' => $this->datetime()
],
'users' => [
'name' => $this->string($max_length=125, $null=false),
'email' => $this->string($max_length=125, $null=false, $key='unique'),
'password' => $this->string($max_length=125),
'backup_pass' => $this->string($max_length=150),
'activation' => $this->string($max_length=225),
'verified' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ),
'created_at' => $this->dateTime(),
'deleted' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" )
],
'contact_us' => [
'name' => $this->string($max_length=125, $null=false),
'email' => $this->string($max_length=125),
'feedback' => $this->string($max_length=1025),
'created_at' => $this->datetime(),
'deleted' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" )
],
'user_sessions' => [
'user_id' => $this->foreign_key($table='users', $column='id', $type = 'int' ),
'session' => $this->string($max_length=225, $null=false),
'user_agent' => $this->string($max_length=225, $null=false),
'push_token' => $this->string($max_length=225, $null=false),
'created_at' => $this->dateTime(),
'deleted' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" )
],
];
return [
'table name' => [ 'column name' => 'value' , 'column name' => 'value' , 'column name' => 'value' ],
'table name' => [...],
];
return [
'users' => [
[
'name' => "Elisha TemmyScope",
'email' => "[email protected] ",
'password' => hash("password"),
'activation' => "random code",
'verified' => "false",
'created_at' => date("Y-m-d h:i:s"),
'deleted' => "false"
]
],
];