Hi to all!
I am pretty new at CI, but in the past two months I managed to learn quite a bit, and I already successfully completed two medium-size web project with this incredible framework.
This is my first serious approach at MVC pattern, and so fa I have to say that CI is really great because of his small footprint, loose dependencies and GREAT documentation.
I became interested in hyerarchical data representation in mysql, and I found this great library.
I am on CI 2.1.0, php 5.3.
I managed to adapt this 1.7.x library to work with CI 2.1 and I am currently correcting few bugs in the code, implementing some new methods and trying to implement transactions.
I am quite a newbie in (my)sql, but if I’m not wrong, it seems that this library does not play well with unstable mysql servers-connections: table locking is implemented but not transactions, and because the queries does not use the “select for update” statement, I think this library is not transaction-safe. There is risk of leaving gaps or breaking the tree if every single query is automatically auto-committed.
I am still a newbie in sql, so I didn’t want to go through an entire query rewriting to remove table locks and rewrite every query in the form of “select for update” statement, to make them transacton and concurrency safe, so I decided to remove internal table locking and manually lock-unlock the tables when calling the library and executing an updating statement. At the same time, setting an autocommit = 0, a commit/rollback and an unlock tables at the right places seems to do the trick well.
Unfortunately I have not documented my editings on mpttree code, but If you confirm me that my work is going in the right direction, I could manage to take some time to tidy up my work and post an updated-modifyed version of mpttree, 2.1.x ready and with some new functions implemented.
For example, I doubled every function making an ***_byid($id) version, because pointing a node with his lft attribute doesn’t play well with concurrency: InnoDB never assigns two identical Ids, but a $lft value intended to point a deleted node could erroneously point at a new/wrong node.. and this is obviously an unwanted behaviour.
I also tested and slightly edited the insert_sorted function, that I see it’s not documented in the manual.
This function allows to insert a node at a specified place, and to order same-level children alphabetically.
This is a GREAT feature, because this way there’s no need to alphabetically order the results of a traversing query, making for a slightly slower insert but for a super fast alphabetically ordered displaying. Great!
==> Let me know if you are interested in some contribution, but please keep in mind that I am quite a newbie in php-sql-ci, so I take no responsibility for problems or anti-patterns I may use.
Thank you 