1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace Category\Lib;
- use Dever;
- class Manage
- {
- public function update($id, $name, $data)
- {
- $info = Dever::param('info', $data);
- if ($info && $info != -1) {
- $update['top_id'] = $info[0];
- $num = count($info)+1;
- $update['level'] = $num;
- $parent = Dever::param('info_id', $data);
- $child = Dever::db('category/info')->one(array('info_id' => $id));
- if (!$child) {
- $update['level'] = -1;
- }
- Dever::db('category/info')->update(array('where_id' => $parent, 'level' => $num - 1));
- } else {
- $update['level'] = 1;
- $update['top_id'] = -1;
- }
- if (isset($update)) {
- $update['where_id'] = $id;
- Dever::db('category/info')->update($update);
- }
- }
- }
|