PHPackages                             smoren/yii2-query-relation-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. smoren/yii2-query-relation-manager

ActiveYii2-extension[Database &amp; ORM](/categories/database)

smoren/yii2-query-relation-manager
==================================

Class for building queries and making result array with relations (single and multiple)

v3.0.0(3y ago)8408MITPHPPHP &gt;=7.4

Since Dec 24Pushed 3y ago3 watchersCompare

[ Source](https://github.com/Smoren/yii2-query-relation-manager)[ Packagist](https://packagist.org/packages/smoren/yii2-query-relation-manager)[ RSS](/packages/smoren-yii2-query-relation-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (22)Used By (0)

yii2-query-relation-manager
===========================

[](#yii2-query-relation-manager)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/459d52fc668b746b87c99a14f47d13845d9e695bc24c4808ea6d6f3bacea82b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736d6f72656e2f796969322d71756572792d72656c6174696f6e2d6d616e61676572)](https://camo.githubusercontent.com/459d52fc668b746b87c99a14f47d13845d9e695bc24c4808ea6d6f3bacea82b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736d6f72656e2f796969322d71756572792d72656c6174696f6e2d6d616e61676572)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8449e4ce4a2beeff0cf0503a278e9e1973db31a1011d4195124e20eb64e56b81/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f536d6f72656e2f796969322d71756572792d72656c6174696f6e2d6d616e616765722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Smoren/yii2-query-relation-manager/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/5916c0fcf50e1c87f2f8660423c4a66a15794e52f65c6b6d13d88e97a812d69b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f536d6f72656e2f796969322d71756572792d72656c6174696f6e2d6d616e616765722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Smoren/yii2-query-relation-manager?branch=master)[![Build and test](https://github.com/Smoren/yii2-query-relation-manager/actions/workflows/test_master.yml/badge.svg)](https://github.com/Smoren/yii2-query-relation-manager/actions/workflows/test_master.yml/badge.svg)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Implements the functionality of getting tree data from a database with one-to-one and one-to-many relationships using only one select-query to the database with flexible conditions configuration.

### How to install to your project

[](#how-to-install-to-your-project)

```
composer require smoren/yii2-query-relation-manager

```

### Usage examples

[](#usage-examples)

Let's say we have these tables in DB with such columns:

- **city** (id, name)
- **address** (id, city\_id, name)
- **place** (id, address\_id, name)
- **comment** (id, place\_id, username, mark, text)

and their corresponding **ActiveRecord** model classes:

- app\\models\\**City**
- app\\models\\**Address**
- app\\models\\**Place**
- app\\models\\**Comment**

```
