{"id":16296761,"url":"https://github.com/pgaultier/tree","last_synced_at":"2025-04-09T13:31:14.793Z","repository":{"id":57062988,"uuid":"54404801","full_name":"pgaultier/tree","owner":"pgaultier","description":"Hazel Tree management for PHP","archived":false,"fork":false,"pushed_at":"2016-03-22T17:10:24.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"devel","last_synced_at":"2025-02-15T07:40:26.473Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgaultier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-21T16:22:43.000Z","updated_at":"2016-03-21T16:23:11.000Z","dependencies_parsed_at":"2022-08-24T14:01:01.234Z","dependency_job_id":null,"html_url":"https://github.com/pgaultier/tree","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Ftree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Ftree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Ftree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Ftree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgaultier","download_url":"https://codeload.github.com/pgaultier/tree/tar.gz/refs/heads/devel","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248049105,"owners_count":21039155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:23:54.725Z","updated_at":"2025-04-09T13:31:14.775Z","avatar_url":"https://github.com/pgaultier.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sweelix Node management\n=======================\n\nSweelix node management is an implementation of Rational numbers to key nested sets\nby Dan Hazel (http://arxiv.org/abs/0806.3115).\n\n\n[![Latest Stable Version](https://poser.pugx.org/sweelix/tree/v/stable)](https://packagist.org/packages/sweelix/tree)\n[![Build Status](https://travis-ci.org/pgaultier/tree.svg?branch=master)](https://travis-ci.org/pgaultier/tree)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/pgaultier/tree/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/pgaultier/tree/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/pgaultier/tree/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/pgaultier/tree/?branch=master)\n[![License](https://poser.pugx.org/sweelix/tree/license)](https://packagist.org/packages/sweelix/tree)\n\n[![Latest Development Version](https://img.shields.io/badge/unstable-devel-yellowgreen.svg)](https://packagist.org/packages/sweelix/tree)\n[![Build Status](https://travis-ci.org/pgaultier/tree.svg?branch=devel)](https://travis-ci.org/pgaultier/tree)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/pgaultier/tree/badges/quality-score.png?b=devel)](https://scrutinizer-ci.com/g/pgaultier/tree/?branch=devel)\n[![Code Coverage](https://scrutinizer-ci.com/g/pgaultier/tree/badges/coverage.png?b=devel)](https://scrutinizer-ci.com/g/pgaultier/tree/?branch=devel)\n\n\nInstallation\n------------\n\nIf you use Packagist for installing packages, then you can update your composer.json like this :\n\n``` json\n{\n    \"require\": {\n        \"sweelix/tree\": \"*\"\n    }\n}\n```\n\nHowto use it\n------------\n\nCreate a Node class and attach the NodeTrait to it. You can look at the class ```Node```.\n\n``` php\nuse sweelix\\tree\\NodeTrait;\n\nclass MyNode {\n    use NodeTrait;\n}\n```\n\nNow you can create a node :\n\n``` php\n$node = new MyNode();\n$node-\u003esetPath('1.2.1');\n\n$leftBorder = $node-\u003egetLeft();\n\n$rightBorder = $node-\u003egetRight();\n\n$treeInfo = $node-\u003egetMatrix()-\u003etoArray();\n\n// insert your node in DB using leftBorder and rightBorder\n// do not forget to also store the tree info\n\n```\n\nNow you can search the node in your DB using regular nested set methods :\n\n```sql\n# find all the children\nselect * from nodes where left \u003e :nodeLeft and right \u003c :nodeRight order by nodeLeft;\n\n# find all the parents\nselect * from nodes where left \u003c :nodeLeft and right \u003e :nodeRight order by nodeRight;\n\n```\n\n\nContributing\n------------\n\nAll code contributions - including those of people having commit access -\nmust go through a pull request and approved by a core developer before being\nmerged. This is to ensure proper review of all the code.\n\nFork the project, create a [feature branch ](http://nvie.com/posts/a-successful-git-branching-model/), and send us a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaultier%2Ftree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgaultier%2Ftree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaultier%2Ftree/lists"}