In yii2 how can i save multiple related records into db into single save call and single transaction. I have two tables:
User - id, name
UserAddress - id , user_id , city
User table has one to many relation to UserAdress table
What i want to do is :
UserAddress ua = new UserAddress();
ua.city = "fff"
User u = new User();
u.name = "test";
u.userAddress = new Array(ua);
u.save();
calling save on user should save user and useraddress with user_id set to user.id as well