Is it possible to set multiple values to Laminas SQL from function?

I am trying to convert this sql code into Laminas way ?
Is it possible to set multiple values ​​to Laminas SQL from function ?

SELECT node.name, (COUNT(parent.name) - 1) AS depth
FROM categories AS node,
        categoies AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.name
ORDER BY node.lft;

It Should be like this but it doesn’t work…

        $sql = new Sql($this->adapter);
        $select = $sql->select();
        $select->columns([
            'categoryId',
            'name',
            'depth' => new Expression("(COUNT(parent.name) - 1)"),
        ]);
        $select->from(new TableIdentifier('categories AS node, categories AS parent'));
        
        $nest = $select->where->nest();
            $nest->and->between('node.lft', 'parent.lft', 'parent.rgt');
        $nest->unnest();

        $select->group(['node.name']);
        $select->order(['node.lft']);

Sql output above the code

SELECT
	`categories AS node, categories AS parent`.`categoryId`,
	`categories AS node, categories AS parent`.`name`,
	( COUNT( parent.NAME ) - 1 ) AS `depth` 
FROM
	`categories AS node, categories AS parent` 
WHERE
	( `node`.`lft` BETWEEN 'parent.lft' AND 'parent.rgt' ) 
GROUP BY
	`node`.`name` 
ORDER BY
	`node`.`lft` ASC

I don’t use laminas-db because it is no longer being developed and relationships are not supported.

But TableIdentifier does not support multiple entries, so you would also have to use Expressions: (not tested!)

$select->columns(
    [
        'categoryId' => new Laminas\Db\Sql\Expression('node.categoryId'),
        'name' => new Laminas\Db\Sql\Expression('node.name'),
        'depth' => new Laminas\Db\Sql\Expression("(COUNT(parent.name) - 1)"),
    ]
);

Btw. in your original SQL query there is no categoryId.