1. Go to this page and download the library: Download e-frank/yii2-data 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/ */
e-frank / yii2-data example snippets
$document = new \x1\data\ActiveDocument([
'model' => Order::className(),
// 'useTransaction' => true,
// 'defaultIncremental' => false,
// 'defaultIgnoreError' => false,
// 'defaultDelete' => true,
// 'defaultScenario' => null,
// 'defaultSkipUpdate' => false,
// 'defaultIgnoreError' => false,
'relations' => [
'orderItems' => [
// 'incremental' => false, // sets relations as passed by data and unlinks omitted rows
// 'skipUpdate' => false, // models are save, otherwise they are skipped
// 'delete' => true, // deletes dropped models, otherwise they are only unlinked
// 'scenario' => null, // the scenario to use for validation
// 'useTransaction' => true, // wraps all operations in a transaction
// 'sortable' => null, // (string) name of the order column (=int field)
'relations' => ['supplier'], // other relations of 'orderItem', maybe nested
]
],
]);
$model = $document->findOne(1); // find the model and quietly attach ActiveDocumentBehavior
$model->load($data); // relations are set!