/** * linked parent and child relation * * @param NodeInterface $descendant child node instance * @param NodeInterface $ancestor parent node instance * @return bool */ public function linkHierarchy(NodeInterface $descendant, NodeInterface $ancestor) { $prefix = $this->conn->getTablePrefix(); $expression = $this->conn->raw(implode(' ', ["insert into {$prefix}{$this->hierarchyTable} (`ancestor`, `descendant`, `depth`) ", "select a.`ancestor`, d.`descendant`, a.`depth` + d.`depth` + 1 ", "from {$prefix}{$this->hierarchyTable} a, {$prefix}{$this->hierarchyTable} d ", "where a.`descendant` = '{$ancestor->id}' and d.`ancestor` = '{$descendant->id}'"])); return $this->conn->statement($expression); }