[Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) |
[eluser]OverZealous[/eluser]
mcnux There are two solutions to your problem. 1) Since you are remapping the client to a different user, the easiest solution is to simply save the clients to the new user. Because each client can only be related to one user (both by rule AND by database design), the new $userTwo->id will be set in $client->user_id. You will still need to load the new Clients on the new User ($userTwo->client->get()) to see the update. Also, the old user will still have the related set in memory for this HTTP request (meaning, $userOne->client->all will still contain a reference). There is no way for DM to know that you are moving clients from one user to another, due to PHP garbage collection limitations. 2) $userOne->delete($client) requires that $client->user_id be able to be stored as NULL. When you set FK rules in most databases, you often need to explicitly allow NULLs, as is mentioned in the docs (under Rules). Please read over your database's docs, and make sure that your rules are not preventing the column from being set as NULL. |
Welcome Guest, Not a member yet? Register Sign In |