yiisoft / yiisoft/active-record

ActiveRecord link() / unlink()

Open
#5 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
119
Forks
38
Avg merge
1h 11m
Merged PRs (30d)
1

Description

Есть 3 таблицы:
Основные:
TableA: id_a, data
TableB: id_b,data

Таблица связей (viaTable):
TableC: id_a, id_b, type

метод link() позволяет создать ссылку по типу:
$modelA->link('relAB', $modelB, ['type' => 1]);
$modelA->link('relAB', $modelB, ['type' => 2]);
что весьма удобно

Метод unlink() не может удалить ссылку с определённым type, он удаляет только всё.
Хотелось бы видеть идентичное поведение у данных методов, а именно возможность задать в unlink() дополнительные параметры.

Q A
Yii version 2.0.15.1
PHP version 7.0
Operating system Debian 9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the ActiveRecord repository by locating the link() and unlink() implementations and their relationship-handling tests, if present. Trace how link() applies the type parameter and determine how unlink() currently selects rows. Done means unlink() can accept additional parameters and remove only the matching relation, with coverage for distinct type values.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.