/** * 批量移动文章 * @param <type> $args */ public function batch_moveAction($args = null) { //move update cid $post_checked = isset($_POST['checked']) ? $_POST['checked'] : null; $newcid = isset($_POST['newcid']) ? $_POST['newcid'] : null; if (is_array($post_checked) && count($post_checked) > 0) { $id_arr = array(); foreach ($post_checked as $val) { $data = unserialize(base64_decode($val)); if ($data->cid != $newcid) { $id_arr[] = $data->id; //更新分类统计 // $c2 = new Category('id', $data->cid); // $c2->count--; // $c2->save(); $tablename = Record::tableFromClass('Category'); $sql = "UPDATE {$tablename} SET count=count-1 WHERE id = '{$data->cid}'"; Record::$__CONN__->query($sql); } } //sql Article::moveIds($id_arr, $newcid); } //更新文章分类统计 $c1 = new Category('id', $newcid); $c1->count = $c1->count + count($id_arr); $c1->save(); del_cache(); go_redirect('index.php?job=admin_article'); }