Created
November 9, 2013 02:20
-
-
Save jraddaoui/7380743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add root term as parent for terms without it | |
$sql = sprintf("UPDATE %s | |
SET parent_id = ? | |
WHERE parent_id IS NULL | |
AND id != ?;", QubitTerm::TABLE_NAME); | |
QubitPdo::modify($sql, array(QubitTerm::ROOT_ID, QubitTerm::ROOT_ID)); | |
// Update rgt value for root term | |
$sql = sprintf("UPDATE %s | |
SET rgt = (SELECT result.new_rgt | |
FROM (SELECT MAX(rgt) + 1 AS new_rgt FROM %s) result) | |
WHERE id = ?;", QubitTerm::TABLE_NAME, QubitTerm::TABLE_NAME); | |
QubitPdo::modify($sql, array(QubitTerm::ROOT_ID)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment