src/Franzose/ClosureTable/Models/ClosureTable.php
public function insertNode($ancestorId, $descendantId)
    {
        $table = $this->getPrefixedTable();
        $ancestor = $this->getAncestorColumn();
        $descendant = $this->getDescendantColumn();
        $depth = $this->getDepthColumn();

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

        DB::connection($this->connection)->statement($query);
    }
public function insertNode($ancestorId, $descendantId)
    {
        $table = $this->getPrefixedTable();
        $ancestor = $this->getAncestorColumn();
        $descendant = $this->getDescendantColumn();
        $depth = $this->getDepthColumn();

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

        DB::connection($this->connection)->statement($query);
    }
public function insertNode ( $ ancestorId , $ descendantId ) { $ table = $ this -> getPrefixedTable ( ) ; $ ancestor = $ this -> getAncestorColumn ( ) ; $ descendant = $ this -> getDescendantColumn ( ) ; $ depth = $ this -> getDepthColumn ( ) ; $ query = "
            INSERT INTO {$table} ({$ancestor}, {$descendant}, {$depth})
            SELECT tbl.{$ancestor}, {$descendantId}, tbl.{$depth}+1
            FROM {$table} AS tbl
            WHERE tbl.{$descendant} = {$ancestorId}
            UNION ALL
            SELECT {$descendantId}, {$descendantId}, 0
        " ; DB :: connection ( $ this -> connection ) -> statement ( $ query ) ; }
Inserts new node into closure table.

@param int $ancestorId
@param int $descendantId
@return void
@throws \InvalidArgumentException
Inserts new node into closure table .