1. Go to this page and download the library: Download roaresearch/yii2-rmdb 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/ */
roaresearch / yii2-rmdb example snippets
use roaresearch\yii2\rmdb\migrations\CreatePivot;
class m170101_000001_product_sale extends CreatePivot
{
public $createdByColumn = 'creation_user';
public $createdAtColumn = 'creation_date';
public function getTableName()
{
return 'product_sale';
}
public function columns()
{
return [
'product_id' => ...,
'sale_id' => ...,
];
}
public function compositePrimaryKeys()
{
return ['product_id', 'sale_id'];
}
}
use roaresearch\yii2\rmdb\migrations\CreateEntity;
class m170101_000001_product extends CreateEntity
{
public $createdByColumn = 'creation_user';
public $createdAtColumn = 'creation_date';
public $updatedByColumn = 'edition_user';
public $updatedAtColumn = 'edition_date';
public function getTableName()
{
return 'product';
}
public function columns()
{
return [
'id' => $this->prymariKey()->...,
'name' => ...,
];
}
}
use roaresearch\yii2\rmdb\migrations\CreatePersistentEntity;
class m170101_000001_sale extends CreatePersistentEntity
{
public $createdByColumn = 'creation_user';
public $createdAtColumn = 'creation_date';
public $updatedByColumn = 'edition_user';
public $updatedAtColumn = 'edition_date';
public $deletedByColumn = 'deletion_user';
public $deletedAtColumn = 'deletion_date';
public function getTableName()
{
return 'product';
}
public function columns()
{
return [
'id' => $this->prymariKey()->...,
'store_id' => ...,
];
}
}