Skip to content

Commit

Permalink
removed bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
franzose committed Jul 8, 2016
1 parent 248ef24 commit 8198a43
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Franzose/ClosureTable/Models/ClosureTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public function insertNode($ancestorId, $descendantId)

$query = "
INSERT INTO {$table} ({$ancestor}, {$descendant}, {$depth})
SELECT tbl.{$ancestor}, ?, tbl.{$depth}+1
SELECT tbl.{$ancestor}, {$descendantId}, tbl.{$depth}+1
FROM {$table} AS tbl
WHERE tbl.{$descendant} = ?
WHERE tbl.{$descendant} = {$ancestorId}
UNION ALL
SELECT ?, ?, 0
SELECT {$descendantId}, {$descendantId}, 0
";

DB::connection($this->connection)->statement($query, [$descendantId, $ancestorId, $descendantId, $descendantId]);
DB::connection($this->connection)->statement($query);
}

/**
Expand Down Expand Up @@ -100,11 +100,11 @@ public function moveNodeTo($ancestorId = null)
SELECT supertbl.{$ancestor}, subtbl.{$descendant}, supertbl.{$depth}+subtbl.{$depth}+1
FROM {$table} as supertbl
CROSS JOIN {$table} as subtbl
WHERE supertbl.{$descendant} = ?
AND subtbl.{$ancestor} = ?
WHERE supertbl.{$descendant} = {$ancestorId}
AND subtbl.{$ancestor} = {$thisDescendantId}
";

DB::connection($this->connection)->statement($query, [$ancestorId, $thisDescendantId]);
DB::connection($this->connection)->statement($query);
}

/**
Expand All @@ -124,19 +124,19 @@ protected function unbindRelationships()
WHERE {$descendantColumn} IN (
SELECT d FROM (
SELECT {$descendantColumn} as d FROM {$table}
WHERE {$ancestorColumn} = ?
WHERE {$ancestorColumn} = {$descendant}
) as dct
)
AND {$ancestorColumn} IN (
SELECT a FROM (
SELECT {$ancestorColumn} AS a FROM {$table}
WHERE {$descendantColumn} = ?
AND {$ancestorColumn} <> ?
WHERE {$descendantColumn} = {$descendant}
AND {$ancestorColumn} <> {$descendant}
) as ct
)
";

DB::connection($this->connection)->delete($query, [$descendant, $descendant, $descendant]);
DB::connection($this->connection)->delete($query);
}

/**
Expand Down

0 comments on commit 8198a43

Please sign in to comment.