Comments (5)
Could you give me your schema / mysql dump?? I've tried on sakila db and it's fine..
Sorry, I don't really get you issue.. What is the error and what it should be?
I'm currently doing this relation-trait by the way..
from yii2-relation-trait.
Sorry, my english is not at best... However as you can see I attached a test database. There are 5 tables:
persons, country, countries, language, languages and several relations. Basically the countries and languages tables are the m:n raltion tables.
Now...everything works fine, as you can see, I created some persons with related data as countries and languages. The problem is, that if I try to update a person and remove for example all the related countries, than try to save it, nothing happens. I mean...everything seems to be ok, no error message, redirecting to the view page, etc. but when I reload the page all the countries are still there. If I remove only one item, everything is fine, the problem occurs only if I remove all the items of one related table.
Also, everything works fine when I remove all the items of both related tables and even if one of the realted tables is already empty. However you can reproduce the issue by creating a person in my attached example. Then relate two countries and two languages. Next, save it. Everything should work. Now try to remove both related countries for example and try to save. As you can see, saving seems to be successfully but the removed countries are still there (no error message).
All the models, controller and views I created with IO Generator of gii
About the "fields" array mentioned in my first post here: in my opinion this should be automatically fixed at the moment when you implement the "composite primary key" as discussed in my other post, so don't care about that.
Thank you for your support and your great work!
from yii2-relation-trait.
Thanks!
from yii2-relation-trait.
Hello mootensai
I unfortunately think I found another mistake. In the attached example I have 4 tables: main (the main table), sub1 (first n:m relation), sub2 (second n:m relation), persons (the target table of the n:m relations).
All the models, controller and views I created with IO Generator of gii and leaved them untouched.
Now if you try to go the main view in yii2 everything works fine, as long as I put in values for only one subquery. At the moment I try to put in values for subquery1 and subquery2 it fails with this error message:
SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 3 column(s)
The SQL being executed was: DELETE FROMsub2
WHERE (mainid
=1) AND ((mainid, personsid, somevalue) NOT IN (('1','1'), ('1','2'), ('1','3'), ('1','2','23')))
Greez
from yii2-relation-trait.
What function do you use?
Please create another issue because it seems like another problem
from yii2-relation-trait.
Related Issues (20)
- loadAll() returns false if no relation in post() HOT 21
- record deleted immediately after insert HOT 8
- Too few arguments to function app\models\base\Dokter::getListDokterRS(), 0 passed and exactly 1 expected HOT 5
- ArgumentCountError Too few arguments to function app\models\base\Poli::getListPoli(), 0 passed and exactly 1 expected
- Error : Too few arguments to function app\models\base\Penilaian::getPenilaianDetsWithParam(), 0 passed and exactly 1 expected
- Unable to locate message source for category 'mtrelt'. HOT 2
- $notDeletedPK - ID's of models came null
- Filtered record being deleted on update HOT 8
- Can't save hasMany relation without index 0 (zero)
- Deletion of has many relation works wrong HOT 1
- update failed with no relation HOT 1
- The object being updated is outdated. HOT 5
- $this->relatedRecords is empty HOT 1
- working with Taggable Behavior
- ID column for Related model doesn't populate on Post
- AR Method afterSave() of related model will be marked as deleted HOT 1
- This extension is pure shit and should be deleted !!! HOT 2
- Feature Request: softDelete()
- deleteWithRelated only works with direct relations
- SaveAll() function Deletes Related Records unexpectedly. HOT 1
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 yii2-relation-trait.