Manage.php 860 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Category\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function update($id, $name, $data)
  7. {
  8. $info = Dever::param('info', $data);
  9. if ($info && $info != -1) {
  10. $update['top_id'] = $info[0];
  11. $num = count($info)+1;
  12. $update['level'] = $num;
  13. $parent = Dever::param('info_id', $data);
  14. $child = Dever::db('category/info')->one(array('info_id' => $id));
  15. if (!$child) {
  16. $update['level'] = -1;
  17. }
  18. Dever::db('category/info')->update(array('where_id' => $parent, 'level' => $num - 1));
  19. } else {
  20. $update['level'] = 1;
  21. $update['top_id'] = -1;
  22. }
  23. if (isset($update)) {
  24. $update['where_id'] = $id;
  25. Dever::db('category/info')->update($update);
  26. }
  27. }
  28. }