PartKeepr\CoreBundle\DoctrineMigrations\Version20150708120022::getLevel PHP Method

getLevel() public method

Returns the level for a given table and ID.
public getLevel ( $table, $id ) : mixed
$table
$id
return mixed
    public function getLevel($table, $id)
    {
        $qb = $this->connection->createQueryBuilder();
        $qb->select('COUNT(*) AS level')->from($table, 'node')->from($table, 'parent')->where('node.lft > parent.lft')->andWhere('node.lft < parent.rgt')->andWhere('node.id = :nodeid');
        return $this->connection->fetchAssoc($qb->getSQL(), [':nodeid' => $id])['level'];
    }