Download the PHP package stefangabos/zebra_mptt without Composer
On this page you can find all versions of the php package stefangabos/zebra_mptt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stefangabos/zebra_mptt
More information about stefangabos/zebra_mptt
Files in stefangabos/zebra_mptt
Package zebra_mptt
Short Description A PHP library providing an implementation of the modified preorder tree traversal algorithm
License LGPL-3.0
Homepage https://github.com/stefangabos/Zebra_Mptt
Informations about the package zebra_mptt
Zebra Mptt
A PHP library providing an implementation of the modified preorder tree traversal (MPTT) algorithm
What is Modified Preorder Tree Traversal
MPTT is a fast algorithm for storing hierarchical data (like categories and their subcategories) in a relational database. This is a problem that most of us have had to deal with, and for which we've used an adjacency list, where each item in the table contains a pointer to its parent and where performance will naturally degrade with each level added as more queries need to be run in order to fetch a subtree of records.
The aim of the modified preorder tree traversal algorithm is to make retrieval operations very efficient. With it you can fetch an arbitrary subtree from the database using just two queries. The first one is for fetching details for the root node of the subtree, while the second one is for fetching all the children and grandchildren of the root node.
The tradeoff for this efficiency is that updating, deleting and inserting records is more expensive, as there's some extra work required to keep the tree structure in a good state at all times. Also, the modified preorder tree traversal approach is less intuitive than the adjacency list approach because of its algorithmic flavour.
For more information about the modified preorder tree traversal method, read this excellent article called Storing Hierarchical Data in a Database.
What is Zebra Mptt
Zebra Mptt is a PHP library that provides an implementation of the modified preorder tree traversal algorithm making it easy to implement the MPTT algorithm in your PHP applications.
It provides methods for adding nodes anywhere in the tree, deleting nodes, moving and copying nodes around the tree and methods for retrieving various information about the nodes.
Zebra Mptt uses table locks making sure that database integrity is always preserved and that concurrent MySQL sessions don't compromise data integrity. Also, Zebra Mptt uses a caching mechanism which has as result the fact that regardless of the type, or the number of retrieval operations, the database is read only once per script execution!
Features
- provides methods for adding nodes anywhere in the tree, deleting nodes, moving and copying nodes around the tree and methods for retrieving various information about the nodes
- uses a caching mechanism which has as result the fact that regardless of the type, or the number of retrieval operations, the database is read only once per script execution
- uses table locks making sure that database integrity is always preserved and that concurrent MySQL sessions don't compromise data integrity
- uses mysqli extension
- has awesome documentation
- code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL
:notebook_with_decorative_cover: Documentation
Check out the awesome documentation!
🎂 Support the development of this project
Your support is greatly appreciated and it keeps me motivated continue working on open source projects. If you enjoy this project please star it by clicking on the star button at the top of the page. If you're feeling generous, you can also buy me a coffee through PayPal or become a sponsor. Thank you for your support! 🎉
Requirements
PHP 5.0.0+, MySQL 4.1.22+
Installation
You can install Zebra Mptt via Composer
Or you can install it manually by downloading the latest version, unpacking it, and then including it in your project
Install MySQL table
Notice a directory called install containing a file named mptt.sql. This file contains the SQL code that will create the table used by the class to store its data. Import or execute the SQL code using your preferred MySQL manager (like phpMyAdmin or the fantastic Adminer) into a database of your choice.