Answer the question
In order to leave comments, you need to log in
How to create a tree in perl from a SQL query?
Good afternoon. Perhaps the title is written crookedly) (A clear influence of Monday morning after a night of work).
The situation is the following. I practice working with OTRS and have an idea to connect all requests with a telephony server. It was decided to write a phone book module, but then he stumbled on a seemingly small trifle: Forming a classifier list in the form of a tree. I understand that the question will most likely need to be solved through recursion. I'm almost new to perl, so don't kick too hard.
There is the following database structure:
<TableCreate Name="phonebook_menu">
<Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="BIGINT"/>
<Column Name="id_parent" Required="false" Type="BIGINT"/>
<Column Name="name" Required="true" Size="250" Type="VARCHAR"/>
<Column Name="created" Required="true" Type="DATE"/>
<Column Name="created_by" Required="true" Type="INTEGER"/>
<Column Name="changed" Required="true" Type="DATE"/>
<Column Name="changed_by" Required="true" Type="INTEGER"/>
<Column Name="valid_id" Required="true" Type="SMALLINT"/>
<Unique Name="phonebook_menu_id">
<UniqueColumn Name="id"/>
</Unique>
<Index Name="phonebook_menu_id">
<IndexColumn Name="id"/>
</Index>
<ForeignKey ForeignTable="valid">
<Reference Local="valid_id" Foreign="id"/>
</ForeignKey>
<ForeignKey ForeignTable="users">
<Reference Local="created_by" Foreign="id"/>
<Reference Local="changed_by" Foreign="id"/>
</ForeignKey>
</TableCreate>
Answer the question
In order to leave comments, you need to log in
The question is not correct. It's not clear exactly what you're after.
On Postgres, you can pull it out as a tree via XML
www.postgresql.org/docs/9.4/static/functions-xml.h...
and then parse as you like.
The following is pursued: It is
necessary to get hashes of hashes in order to process it later and display the list of categories on the page in the form of a ul>li list. And then use the www.jstree.com/docs/json plugin .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question