Comments (6)
:), if this was an algorithm, all the issues would have been closed at once
from active-record.
How do you expect the entry in the relation table to be created when the model has no primaryKey value assigned?
from active-record.
sure you are right. i wished i found some automagic here and expected a 'linked save' to save the complete model-tree. [or the same behaviour with and without ->viaTable
. with viaTable the child model is saved, without isn't.]
when you use ->link
a second time, you will get an additional row in the relation table, and no error, if you don't have an unique index.
i didn't find anything like a isLinked
method, so what i think i have to do is test the parent relationship for an existing child by the child's primary key, like:
$hasChild = $parent->getRelation($relation)->andWhere('id=1')->exists();
and then decide if you need ->link
.
i am working on a hydrator and hope to publish it asap.
still: fantastic work!
from active-record.
closed in favor of https://github.com/yiisoft/yii2/issues/4834
from active-record.
@dynasource this issue is #4834 :)
from active-record.
from active-record.
Related Issues (20)
- Error after update yiisoft/factory
- After PR #165 connection created every time when create an AR entity HOT 1
- Is it really necessary tableName as non static method? HOT 1
- ActiveRecord::insert(). When writing, it does not write fields. HOT 1
- update link
- Cannot serialize active record
- Use global `\InvalidArgumentException`
- Can ActiveRecord implement the interface ArrayableInterface, like Yii2? HOT 1
- `ActiveQuery` class should not extend `Yiisoft\Db\Query\Query` HOT 1
- Remove flag arguments from AR methods
- The method allPopulate in ActiveQuery will execute populate twice during execution
- PHPUnit 9.6.15 Warning - The configuration file did not pass validation!
- TableName() has no effect HOT 1
- update irc link
- The parameter identical of the method isAttributeChanged in class BaseActiveRecord has no effect when its value is false. HOT 2
- Yiiboot\ActiveRecord\ActiveRecord::populateRelation() not support the scalar type HOT 2
- Remove `psalm83.xml` after raising PHP version to `8.3`
- Summary for `ActiveRecord` HOT 4
- Realize `ReadOnlyActiveRecord` HOT 4
- Remove parameter `$throwException` from `ActiveRecordInterface::relationQuery()`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active-record.