1. Go to this page and download the library: Download yii2tech/filedb 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/ */
use yii2tech\filedb\Query;
$query = new Query();
$query->from('UserGroup')
->limit(10);
$rows = $query->all();
$query = new Query();
$row = $query->from('UserGroup')
->where(['name' => 'admin'])
->one();
class UserGroup extends \yii2tech\filedb\ActiveRecord
{
public static function fileName()
{
return 'UserGroup';
}
}
class UserGroup extends \yii2tech\filedb\ActiveRecord
{
public function getUsers()
{
return $this->hasMany(User::className(), ['groupId' => 'id']);
}
}
class User extends \yii\db\ActiveRecord
{
public function getGroup()
{
return $this->hasOne(UserGroup::className(), ['id' => 'groupId']);
}
}