We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to translate this sql to query builder statments?

insert into tree_path (ancestor, descendant, path_length)
select ancestor, $new_id, path_length + 1
from tree_path
where descendant = $node_id
select $new_id, $new_id, 0

assume that there is a model tree_path for the table tree_path, thanks.

I think that you could creat procedure .