/** * unrelated file * * @param string $targetId target identifier * @param string $id file identifier * @return void * @throws Exception */ public function unRelating($targetId, $id) { if ($row = $this->findRelationOne($targetId, $id)) { $this->conn->beginTransaction(); try { $row = (array) $row; $this->conn->table($this->relationTable)->where('id', $row['id'])->delete(); $this->conn->table($this->table)->where('id', $id)->orWhere('parentId', $id)->decrement('useCount'); } catch (Exception $e) { $this->conn->rollBack(); throw $e; } $this->conn->commit(); } }