Skip to content

Commit 27b7205

Browse files
committed
add editCate
1 parent 491c6e5 commit 27b7205

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

shop/app/model/CategoryModel.class.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,23 @@ public function getById($cat_id){
8080
return $this->db->fetchRow($sql);
8181
}
8282

83-
public function pdateCat($data){
83+
public function updateCat($data){
84+
//上级id不能为自己和后代ID
8485
$child_list = $this->getList($data['cat_id']);
8586
$ids = array($data['cat_id']);
8687
foreach ($child_list as $row) {
88+
$ids[] = $row['cat_id'];
89+
}
8790

91+
if (in_array($data['parent_id'],$ids)) {
92+
$this->error_info = '不能为自己或后带分类的字分类';
93+
return false;
8894
}
8995

90-
$sql = "update demo_category "
96+
//echo $data['cat_id'];die();
97+
98+
$sql = "update demo_category set cat_name='{$data['cat_name']}',sort_order={$data['sort_order']},parent_id={$data['parent_id']} where cat_id={$data['cat_id']}";
99+
return $this->db->query($sql);
91100
}
101+
92102
}

0 commit comments

Comments
 (0)