bartko-s / stefano-tree

Framework agnostic Nested Set (MPTT) implementation for PHP
https://bartko-s.github.io/stefano-tree
BSD 3-Clause "New" or "Revised" License
28 stars 8 forks source link

Multiple tree in one DB table #5

Closed tomasfejfar closed 8 years ago

tomasfejfar commented 8 years ago

I added test as well, which only works with ZF1 adapter. I don't use the other adapters so I don't know how to test/implement it properly. Tests still pass for all adapters.

I understand that master moved in the meantime. There is a lot of conflicts and this may not at all be mergeable, but I still opened this PR in case you wanted to use some parts of it.

bartko-s commented 8 years ago

What is the purpose of this PR? Could you give me more information?

tomasfejfar commented 8 years ago

The ZF1 adapter implementation did not work correctly when using custom db select that contained "wheres". I had a case for that when I added MPTT functionality to existing pages table and I needed the class to work only on rows with show_in_menu == 1. I set the select - quite alike to how I do it in the test here - and it completly broke the MPTT, because it used WHERE show_in_menu = 1 for selects, but not for updates. This PR fixes the issue by pulling the "WHERE" data from the select and using it appropriately for UPDATE and DELETE statements.

tomasfejfar commented 8 years ago

In the first commit it adds one column (irrelevant to MPTT) to the test data to allow testing of other adapters later. The row should be ignored by default (which it is - that's why tests still work for other adapters). And I use it for ZF1 adapter test

bartko-s commented 8 years ago

Current stable version v.1.5.0 support only one tree per table. The purpose of method "setDefaultDbSelect" is for use case where you need to join db table. That mean it does not work correctly with "WHERE".

tomasfejfar commented 8 years ago

It does in this PR :) Although I do understand now what was the original case.

bartko-s commented 8 years ago

Hi @tomasfejfar . What are you think about CakePHP multi trees implementation? I think it is flexible implementation.

bartko-s commented 8 years ago

Scope support implemented(develop branch). Will be released in next stable minor version.