How to delete all user roles in Kohana 3 -
I'm using the ORM AUTH module and it's hard to understand how to do it. I have tried this matter:
$ user = ORM :: factory ('user', $ id); $ User-> roles-> delete_all ();
and error error exception [fatal error]: Call undefined method Database_Query_Builder_Delete :: join ()
However $ user-> ; Roles - & gt; Find_all ();
gives me exactly what I need.
Instead of removing roles from the database, what you want to do, the relationships between the user model and the roles model Remove it You can use.
foreach ($ user- & gt; roles- & gt; find_all ($) as role) {$ user- & gt; Remove ('roles', $ roles); }
Comments
Post a Comment