public function removeUserFromRole($userId, $roleId) { if (User::instance($this->preferences, $this->db)->findById($userId) && Role::instance($this->preferences, $this->db)->findById($roleId)) { try { $sql = "DELETE FROM rpd_user_has_role WHERE id_user = :userId AND id_role = :roleId"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':userId', $userId, PDO::PARAM_INT); $stmt->bindParam(':roleId', $roleId, PDO::PARAM_INT); return $stmt->execute(); } catch (\PDOException $e) { MySQL::instance()->showException($e); } } return false; }
/** * @return Role */ public function role() { return Role::instance($this->preferences, $this->mysql->getHandler()); }
public function removeUsersFromRole($roleId) { if (Role::instance($this->preferences, $this->db)->findById($roleId)) { try { $sql = "DELETE FROM rpd_user_has_role WHERE id_role = :idRole"; $stmt = $this->db->prepare($sql); $this->id = (int) $roleId; $stmt->bindParam(':idRole', $this->id, PDO::PARAM_INT); return $stmt->execute(); } catch (\PDOException $e) { MySQL::instance()->showException($e); } } return false; }