コード例 #1
0
ファイル: tree.php プロジェクト: CrazyBobik/allotaxi.test
 public static function fixPids($startId)
 {
     $treeTable = new K_Tree_Model();
     $result = $treeTable->select(array('tree_lkey', 'tree_rkey', 'tree_level'))->where('`tree_id`=' . (int) $startId)->fetchArray();
     if (count($result) == 0) {
         throw new Exception('db_err_fixpid db_err_norootd ' . $startId);
     }
     list($lKey, $rKey, $level) = array($result[0]['tree_lkey'], $result[0]['tree_rkey'], $result[0]['tree_level']);
     if ($rKey - $lKey == 1) {
         return;
     }
     // Вложенных элементов нет.
     $result = $treeTable->select(array('tree_id', 'tree_lkey', 'tree_rkey', 'tree_level'))->where('`tree_lkey` BETWEEN ' . $lKey . ' AND ' . $rKey . ' AND `tree_rkey`-`tree_lkey` > 1')->order('tree_level')->fetchArray();
     $upds = array();
     while (list($k, $f) = each($result)) {
         $upds[] = $f;
     }
     // Перебираем все элементы, у которых есть дочерние элементы.
     foreach ($upds as $cUpd) {
         $treeTable->update(array('tree_pid' => $cUpd['tree_id']), '`tree_lkey`=' . $cUpd['tree_lkey'] . ' AND `tree_rkey` < ' . $cUpd['tree_rkey'] . ' AND `tree_level`=' . ($cUpd['tree_level'] + 1));
     }
     return true;
 }
コード例 #2
0
ファイル: tree.php プロジェクト: CrazyBobik/allotaxi.test
         $returnJson['status'] = true;
     } else {
         $returnJson['status'] = false;
     }
     $this->putJSON($returnJson);
 }
 public function updateAction()
 {
     $this->disableRender = true;