doulun1915 2018-12-03 16:36
浏览 17

多个块注释中的问题,但是单个注释成功阻止

The issue is multiple when i block multiple comment it is not working. if i block single comment it working success fully. please read my HTML & PHP code and tell me solution for this issue.

Html code for checkbox

 <input class="allCheck" type="checkbox" name="check12[]" value="<?php
         echo $d['ID']; ?>" />

PHP controller: Here is define two method for dataAccess

public function multipleBlockAction() {

    $request = $this->request;
    $arrdatas = array();
    $commentsValues = $request->getPost("check12");

    $sizeOfvalue = sizeof($commentsValues) - 1;

    for ($x = 0; $x <= $sizeOfvalue; $x++) {

        $checkOneByOne = $commentsValues[$x];

        $commentdata = $this->_commentservice->getCommentById($checkOneByOne);

        foreach ($commentdata as $ucdata) {

            $arrdatas = $ucdata->toArray();
            $arrdatas['Status'] = '2';
            $arrdatas['Block_DateTime'] = date('Y-m-d H:i:s');

            $result = $this->_commentservice->totrashcomment($arrdatas);

            if (is_object($result)) {
                $result = $result->getMessages();
                $this->logErrorMessage($result);
            foreach ($result as $res) {
                $this->flash->error($res);
            }
            } else {
                $this->flashSession->success('<div  class="alert alert-success text-center">Comment is Blocked successfully</div>');
                $previous = $this->session->get('previous_url');
                return $this->response->redirect($previous);
            }



        }

    }

} 

getCommentById: i have mention about this method and it is calling on controller.

public function getCommentById($comid) {
        try {
            $transaction = $this->_transaction->get();
            $this->_userComment->setTransaction($transaction);
            $result = $this->_userComment->find("ID = '{$comid}'");
            return $result;
        } catch (TxFailed $e) {
            return $this->_userComment;
        }
    }

totrashcomment: this method is also calling on controller

public function totrashcomment($data) {
        //print_r();
        try {

            $transaction = $this->_transaction->get();
            $this->_userComment->setTransaction($transaction);

            $conditions = "Unique_ID = {$data['Unique_ID']} and MainComment = '1'";
            $data1 = $this->_userComment->find(array($conditions))->toArray();
            if (count($data1) > 0) {
                return;
            } else {
                if ($this->_userComment->save($data) == false) {
                    $transaction->rollback('comment not updated');
                }
            }
            //Everything goes fine, let's commit the transaction
            $transaction->commit();
        } catch (TxFailed $e) {
            return $this->_userComment;
        }
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度