如何在我的树枝中调用此功能

时间:2016-07-14 01:02:41

标签: php mysql symfony

表1(ediTransaction) - >文件名
表2(edi997Details) - >反

我正在创建一个页面,我将显示文件名及其trans。我的目标是我想用相同的transactionId显示文件名对应的trans。我对此感到困惑,我无法显示其反式,但出现了错误:

  

在渲染模板期间抛出了异常   (" [语义错误]第0行,第86行附近' b WHERE a.ediTransaction':   错误:类Matrix \ MatrixEdiBundle \ Entity \ Edi997Details没有   名为edi997Details")的协会   MatrixEdiBundle:Matrix:asn.html.twig at 88。

TWIG

  {% for trans in trans %}
        <td>
           {{trans.ediTransaction.fileName}}
        </td>
       <td>
       {%
         set trans=render(controller('MatrixEdiBundle:Matrix:getStatus',{'ediTransactionId' : trans.ediTransactionId}))
       %} //this is for calling the trans and I think this is wrong. Help me with this one.
      </td>
     {% endfor %}

CONTROLLER //用于文件名,这样可以正常使用

 public function FileAction(Request $request,$page) {

    $fileName      = $request->query->get('fileName');
    $sort          = $request->query->get('sort');

    $max_records = 15 ;
    $em = $this->getDoctrine()->getManager();

    $data = $em->getRepository('MatrixEdiBundle:EdiTransaction')->getAsnDetails($fileName, $page, 15);

    $count = $data->count();
    $pagination = array(
      'page'          => $page,
      'route'         => 'matrix_edi_asn',
      'route_params'  => array(),
      'fileName'      => $fileName,
      'sort'          => $sort
    );

    if ($max_records > 0 ) {
      $pagination['pages_count'] = max(ceil($count / $max_records), 1);
      return $this->render('MatrixEdiBundle:Matrix:asn.html.twig', array('trans' => $data,'pagination' => $pagination));
    }
  }

CONTROLLER FOR TRANS(需要更多编辑,调用trans的功能)

 public function getStatusAction($ediTransactionId) {

    $em = $this->getDoctrine()->getManager();
    $trans = $em->getRepository('MatrixEdiBundle:Edi997Details')->getStatus($ediTransactionId);
    $response = 0;

    if($trans != null) {
      foreach ($trans as $key) {
        $noOfTrans = $key->getnoOfTrans();

        $response = $noOfTrans;
      }
    }
    return new Response($response);
  }

Edi997DetailsRepository(trans所在的位置)

public function getStatus($ediTransactionId){
            $em = $this->getEntityManager();
            $query = $em->createQuery(
                'SELECT a,b FROM MatrixEdiBundle:edi997Details a
                 JOIN a.ediTransaction b
                 WHERE a.ediTransaction = :TransactionId')
                 ->setParameter('TransactionId', $ediTransactionId);

                return $query->getResult();

        }

我遇到了很多错误,我知道我的代码有问题,我需要有人帮我这个。感谢。

0 个答案:

没有答案