检索标志= 0?

时间:2016-05-12 02:40:04

标签: php symfony

我在页面中有一个表有一个动作按钮,当单击按钮我想要的是文件标志将在该文件的数据库表中设置为0,该文件将被插入另一个名为archive的表中因为我不知道如何检索同一个文件并将其插入存档表中,我遇到了麻烦,请帮忙,我正在做symfony2 ,.? ?

这是我正在使用的功能:

    public function rejectedTransFielArchiveAction(){
    $em = $this->getDoctrine()->getManager();
    $transaction = $em->getRepository('MatrixEdiBundle:EdiTransaction')->findDocument($transactionId);

    $user = $this->get('security.context')->getToken()->getUser();
    $username = $user->getUsername();
    $date = new \DateTime(date('Y-M-d H:m:s'));

    $rejectedTransArchive = new Edi997DetailsArchive();

    foreach ($transaction as $key) {
      $senderId = $key->getSenderId();
      $receiverId = $key->getReceiverId();
      $IsaNumber = $key->getIsaNumber();
      $transactionDate = $key->getTransactionDate();
      $gsNumber = $key->getGsNumber();
      $fileName = $key->getFileName();
    }

    $rejectedTransArchive->setSenderId($senderId);
    $rejectedTransArchive->setReceiverId($receiverId);
    $rejectedTransArchive->setIsaNumber($IsaNumber);
    $rejectedTransArchive->setTransactionDate($transactionDate);
    $rejectedTransArchive->setGsNumber($gsNumber);
    $rejectedTransArchive->setFileName($fileName);

    $em->persist($rejectedTransArchive);
    $em->flush();

    if ($transactionId != null) {
      $transDetail = $em->getRepository('MatrixEdiBundle:EdiTransactionDetail')->getDetails($transactionId);

      foreach($transDetail as $key) {
        $transDetailArchive = new EdiTransactionDetailArchive();

        $transDetailArchive->setEdiTransactionId($transactionArchive->getEdiTransactionId());
        $transDetailArchive->setRefNumber($key->getRefNumber());
        $transDetailArchive->setPoNumber($key->getPoNumber());
        $transDetailArchive->setInvoiceNumber($key->getInvoiceNumber());
        $transDetailArchive->setAsnNumber($key->getAsnNumber());
        $transDetailArchive->setAdjNumber($key->getAdjNumber());
        $transDetailArchive->setAmount($key->getAmount());

        $em->persist($transDetailArchive);
      }
    }

      $removeTransaction = $em->getRepository('MatrixEdiBundle:EdiTransaction')->findOneByEdiTransactionId($transactionId);
      $em->remove($removeTransaction);

      $em->flush();

      $session = $this->getRequest()->getSession();
      $session->getFlashbag()->add('message', $fileName.' has been archived.');

      return $this->redirect($this->generateUrl('matrix_edi_view'));
  }

0 个答案:

没有答案