聯系官方銷售客服
1835022288
028-61286886
//我在模塊表單中些批量審核通過方法,審核完后更新關聯主題中length的字段值,現在測試完,數據表只更新一個所選內容的字數,不知道哪里除了問題。。 // 后臺批量審核 protected function _Admin_Status() { $tid = intval(\Phpcmf\Service::L('input')->get('tid')); $ids = \Phpcmf\Service::L('input')->get_post_ids(); if (!$ids) { $this->_json(0, dr_lang('所選數據不存在')); } // 格式化 $in = []; foreach ($ids as $i) { $i && $in[] = intval($i); } if (!$in) { $this->_json(0, dr_lang('所選數據不存在')); } $rows = \Phpcmf\Service::M()->db->table($this->init['table'])->whereIn('id', $in)->get()->getResultArray(); if (!$rows) { $this->_json(0, dr_lang('所選數據不存在')); } foreach ($rows as $row) { if ($row['status'] != 1) { if ($tid) { // 拒絕 $this->_verify_refuse($row); } else { // 通過 //本章字數 $slength = $row['length']; //書籍原字數 $clength = \Phpcmf\Service::L('vwbook',APP_DIR)->cdata($row['cid'],'length'); //|--更新書籍字數 ///* \Phpcmf\Service::M()->table(dr_module_table_prefix(APP_DIR))->update($row['cid'], [ 'length' => $slength + $clength ]); //*/ var_dump($row); //$this->_verify($row); } $this->content_model->update_form_total($row['cid'], $this->form['table']); } } //$this->_json(1, dr_lang('操作成功')); }
vwbook->cdata方法(此項數據無誤,我一并貼出來方便尋找錯誤根源):
// 用于列表關聯字段 public function cdata($cid, $field = 'id') { if (!$cid) { return dr_lang('未關聯'); } $mid = defined('MOD_DIR') ? MOD_DIR : ''; $this->cid_data[$cid] = isset($this->cid_data[$cid]) && $this->cid_data[$cid] ? $this->cid_data[$cid] : \Phpcmf\Service::M()->table_site($mid)->get($cid); return $this->cid_data[$cid] ? $this->cid_data[$cid][$field] : dr_lang('關聯主題不存在'); }
回復@天天向上 我是直接復制官方模塊表單的方法過來修改的
回復@天天向上 所以我是想弄明白,現在更新為啥出現問題,這個批量其實用的很少,審核都需要進去看內容的。這個功能不需要考慮性能問題
回復@天天向上
我組合數組,但是得到的結果還是一條。所以跟你說的這個問題不相干啊。官方還給你點贊。。。。
問題的點沒有找到不是?
過來結帖,但是那個foreach為啥沒起作用還是沒搞明白哪里除了問題,換成以下代碼可以解決。