문제

I'm using ORM Auth module and it's difficult to figure out how to do it. I've tried this case:

$user = ORM::factory('user', $id);
$user->roles->delete_all();

And got error ErrorException [ Fatal Error ]: Call to undefined method Database_Query_Builder_Delete::join()

However $user->roles->find_all(); gives me exactly what i want.

도움이 되었습니까?

해결책

Instead of deleting roles from the database, what you want to do is remove the relationships between the user model and the roles model. You can use the ORM remove() method.

foreach ($user->roles->find_all() as $role)
{
    $user->remove('roles', $role);
}

다른 팁

According to version 3.1.3.1 code for Kohana_ORM class, the ORM method "remove($alias, $far_keys=NULL)" if you do not pass the second parameter, it will destroy all related entries.

$user->remove('roles');

Just create a ticket for this feature. You can use a code suggested.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top