<tfoot id='TISYP'></tfoot>

  • <small id='TISYP'></small><noframes id='TISYP'>

  • <legend id='TISYP'><style id='TISYP'><dir id='TISYP'><q id='TISYP'></q></dir></style></legend>

      <bdo id='TISYP'></bdo><ul id='TISYP'></ul>
  • <i id='TISYP'><tr id='TISYP'><dt id='TISYP'><q id='TISYP'><span id='TISYP'><b id='TISYP'><form id='TISYP'><ins id='TISYP'></ins><ul id='TISYP'></ul><sub id='TISYP'></sub></form><legend id='TISYP'></legend><bdo id='TISYP'><pre id='TISYP'><center id='TISYP'></center></pre></bdo></b><th id='TISYP'></th></span></q></dt></tr></i><div id='TISYP'><tfoot id='TISYP'></tfoot><dl id='TISYP'><fieldset id='TISYP'></fieldset></dl></div>

      1. Symfony 3.0 嵌套实体不保存

        Symfony 3.0 nested entities not saving(Symfony 3.0 嵌套实体不保存)
        <tfoot id='3MlNM'></tfoot>
      2. <legend id='3MlNM'><style id='3MlNM'><dir id='3MlNM'><q id='3MlNM'></q></dir></style></legend>
          <tbody id='3MlNM'></tbody>

            <i id='3MlNM'><tr id='3MlNM'><dt id='3MlNM'><q id='3MlNM'><span id='3MlNM'><b id='3MlNM'><form id='3MlNM'><ins id='3MlNM'></ins><ul id='3MlNM'></ul><sub id='3MlNM'></sub></form><legend id='3MlNM'></legend><bdo id='3MlNM'><pre id='3MlNM'><center id='3MlNM'></center></pre></bdo></b><th id='3MlNM'></th></span></q></dt></tr></i><div id='3MlNM'><tfoot id='3MlNM'></tfoot><dl id='3MlNM'><fieldset id='3MlNM'></fieldset></dl></div>
              1. <small id='3MlNM'></small><noframes id='3MlNM'>

                  <bdo id='3MlNM'></bdo><ul id='3MlNM'></ul>

                • 本文介绍了Symfony 3.0 嵌套实体不保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我有一个实验实体,它有许多 RNASeq 实体.但是,当我尝试使用 RNASeq 条目(通过 newAction)保存实验时,只有实验部分会保存.

                  So I have an Experiment Entity which has many RNASeq entities. However, when I try to save an Experiment with an RNASeq entry (via the newAction), only the Experiment portion saves.

                  我的控制器如下:

                      <?php
                      // src/AppBundle/Controller/ExperimentController.php
                      namespace AppBundleController;
                  
                      use AppBundleEntityExperiment;
                      use AppBundleEntityRNASeq;
                      use AppBundleFormTypeExperimentType;
                      use SymfonyBundleFrameworkBundleControllerController;
                      use SymfonyComponentHttpFoundationRequest;
                      use SensioBundleFrameworkExtraBundleConfigurationRoute;
                      use SymfonyComponentHttpFoundationResponse;
                  
                      // TODO: deleteAction should be implemented. 
                  
                      class ExperimentController extends Controller {
                          /**
                           * @Route("/experiment/index", name="experiment_index")
                           */
                          public function indexAction() {
                              // Grab all experiments from database and hand them to template. 
                              $repository = $this->getDoctrine()->getRepository('AppBundle:Experiment');
                              $experiments = $repository->findAll();
                              return $this->render('experiment/index.html.twig',['experiments' => $experiments]);
                          }
                  
                          /**
                           * @Route("/experiment/new", name="experiment_new")
                           */
                          public function newAction(Request $request) {
                              $experiment = new Experiment();
                  
                              $form = $this->createForm(ExperimentType::class, $experiment);
                  
                              $form->handleRequest($request);
                  
                              // On submission.
                              if ($form->isValid()) {
                                  $em = $this->getDoctrine()->getManager();
                                  $em->persist($experiment);
                                  // For each nested object. 
                                  foreach($experiment->getRNASeqs() as $rnaseq) {
                                      $em->persist($rnaseq);
                                  }
                                  $em->flush();
                                  return $this->redirectToRoute('experiment_index');
                              }
                  
                              return $this->render('experiment/form.html.twig', array('form' => $form->createView()));
                          }
                  
                          /**
                           * @Route("/experiment/show/{id}", name="experiment_show")
                           * TODO: Not sure if nessesary (wasn't in last system).
                           */
                          public function showAction($id) {
                              return $this->render('experiment/show.html.twig');
                          }
                  
                          /**
                           * @Route("/experiment/edit/{id}", name="experiment_edit")
                           */
                          public function editAction(Request $request, $id) {
                              $repository = $this->getDoctrine()->getRepository('AppBundle:Experiment');
                              $experiment = $repository->find($id);
                  
                              $form = $this->createForm(ExperimentType::class, $experiment);
                  
                              $form->handleRequest($request);
                  
                              return $this->render('experiment/form.html.twig', array('form' => $form->createView()));
                          }
                  
                  }
                    ?>
                  

                  我试图遵循 Symfony 文档.然而,它并没有专门讨论一对多的例子,我担心这可能是我搞砸的地方.

                  I've attempted to follow the Symfony documentation. However, it doesn't specifically go over a One-to-Many example, and I fear this is possibly where I've messed up.

                  为了简洁起见,可以找到我的实体类和我的其余代码 此处.

                  For the sake of brevity my Entity classes and the rest of my code can be found here.

                  我注意到在创建事件期间,insert into 事件似乎没有正确的关系属性:

                  I've noticed that during a creation event, the insert into events don't seem to have the correct relationship attributes:

                      INSERT INTO experiment (title, exp_type, sample_nums) VALUES (?, ?, ?)
                  Parameters: { 1: fe, 2: RNASeq, 3: 'a:1:{i:0;i:68767;}' }
                  
                      INSERT INTO rnaseq (quality, ribodepleted, final_quality, sample_num, protocol_used, step1, step1result, service_provider, platform, data_files, pipeline, pipeline_parameters, result_files, experiment_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
                  Parameters: { 1: fds, 2: 0, 3: fes, 4: 7876, 5: esf, 6: 0, 7: fsd, 8: fs, 9: fs, 10: fsd, 11: sdf, 12: fds, 13: fsd, 14: null }
                  

                  Experiment 似乎缺少对其 rnaSeqs 属性的更新,并且 RNASeq 有一个 null 参数用于experiment_id.

                  Experiment appears to be missing an update to its rnaSeqs attribute, and RNASeq has a null parameter for experiment_id.

                  推荐答案

                  这是一个非常常见的问题.您需要注意交叉引用您的对象.尽管许多人最初似乎认为它会自动执行,但学说不会自动执行此操作.

                  This is a very common issue. You need to take care of cross referencing your objects. Doctrine does not do this automatically though many people initially seem to think it will.

                  class Experiment {
                    public function addRNASeq($seq) {
                      $this->seqs[] = $seq;
                      $seq->setExperiment($this);  // This is what you are missing
                  

                  并将属性 cascade=all 添加到您的 Experiment::seqs 属性中.那么你就不需要显式地持久化 seq 实体.

                  And add the attribute cascade=all to your Experiment::seqs property. Then you won't need to explicitly persist the seq entities.

                  这篇关于Symfony 3.0 嵌套实体不保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <tbody id='kXivL'></tbody>

                      <small id='kXivL'></small><noframes id='kXivL'>

                        <legend id='kXivL'><style id='kXivL'><dir id='kXivL'><q id='kXivL'></q></dir></style></legend>

                        <tfoot id='kXivL'></tfoot>

                          <bdo id='kXivL'></bdo><ul id='kXivL'></ul>
                        • <i id='kXivL'><tr id='kXivL'><dt id='kXivL'><q id='kXivL'><span id='kXivL'><b id='kXivL'><form id='kXivL'><ins id='kXivL'></ins><ul id='kXivL'></ul><sub id='kXivL'></sub></form><legend id='kXivL'></legend><bdo id='kXivL'><pre id='kXivL'><center id='kXivL'></center></pre></bdo></b><th id='kXivL'></th></span></q></dt></tr></i><div id='kXivL'><tfoot id='kXivL'></tfoot><dl id='kXivL'><fieldset id='kXivL'></fieldset></dl></div>