• <legend id='TpFdo'><style id='TpFdo'><dir id='TpFdo'><q id='TpFdo'></q></dir></style></legend>
      <bdo id='TpFdo'></bdo><ul id='TpFdo'></ul>

  • <tfoot id='TpFdo'></tfoot>

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

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

        Symfony2 Doctrine Custom Repository Class [Semantical Error]

        Symfony2 Doctrine Custom Repository Class [Semantical Error] line 0, col 14 near #39;Project p#39;: Error: Class #39;Project#39; is not defined(Symfony2 Doctrine Custom Repository Class [Semantical Error] line 0, col 14 near Project p: Erro
        <tfoot id='cEXUI'></tfoot>
          <bdo id='cEXUI'></bdo><ul id='cEXUI'></ul>

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

                  <tbody id='cEXUI'></tbody>
                <i id='cEXUI'><tr id='cEXUI'><dt id='cEXUI'><q id='cEXUI'><span id='cEXUI'><b id='cEXUI'><form id='cEXUI'><ins id='cEXUI'></ins><ul id='cEXUI'></ul><sub id='cEXUI'></sub></form><legend id='cEXUI'></legend><bdo id='cEXUI'><pre id='cEXUI'><center id='cEXUI'></center></pre></bdo></b><th id='cEXUI'></th></span></q></dt></tr></i><div id='cEXUI'><tfoot id='cEXUI'></tfoot><dl id='cEXUI'><fieldset id='cEXUI'></fieldset></dl></div>
                  <legend id='cEXUI'><style id='cEXUI'><dir id='cEXUI'><q id='cEXUI'></q></dir></style></legend>
                1. 本文介绍了Symfony2 Doctrine Custom Repository Class [Semantical Error] line 0, col 14 near 'Project p': Error: Class 'Project' is not defined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Symfony 2 和 Doctrine 的新手,有一个简单的问题:

                  I'm really new in Symfony 2 and Doctrine, and have a simple problem:

                  我的存储库中有一段非常简单的代码:

                  There is a pretty simple code in my repository:

                  <?php
                  
                  namespace BakeryITBakeryBundleEntity;
                  
                  use DoctrineORMEntityRepository;
                  
                  class ProjectRepository extends EntityRepository
                  {
                      public function findHistory(){
                          return $this->getEntityManager()
                          ->createQueryBuilder()
                          ->select('p')
                          ->from('Project','p')
                          ->getQuery()
                          ->getResult();
                      }
                  }
                  

                  我的控制器中有两个简单的函数:

                  And two simple functions in my controller:

                  <?php
                  
                  namespace BakeryITBakeryBundleController;
                  
                  /*
                  ...
                  */
                  
                  class ProjectController extends Controller
                  {
                      public function indexAction()
                      {
                          return $this->index('Project', 'findHistory');
                      }
                  }
                  

                  控制器看起来像这样:

                  public function index($entity, $query = 'findAll')
                  {
                      $repository = $this->getDoctrine()
                          ->getRepository('BakeryBundle:'.$entity);
                  
                      $data = $repository->$query();
                  
                      return $this->render('BakeryBundle:'.$entity.':index.html.twig',
                      array('data' => $data));
                  }
                  

                  此代码向我抛出语义错误 [语义错误] 行 0,'Project p' 附近的第 14 列:错误:未定义类 'Project'.

                  This code throw me the Semantical Error [Semantical Error] line 0, col 14 near 'Project p': Error: Class 'Project' is not defined.

                  另一方面,如果我更改存储库中的这一行,则一切正常:

                  On the other hand everything works perfectly if I change this line in my repository:

                  ->from('Project','p')
                  

                  ->from('BakeryITBakeryBundleEntityProject','p')
                  

                  我不知道为什么这个例子在第一种情况下不起作用.我的 BakeryITBakeryBundleEntityProject 中的命名空间是这样设置的:

                  I don't know why this example doesn't work in the first case. Namespace in my BakeryITBakeryBundleEntityProject is set in this way:

                  namespace BakeryITBakeryBundleEntity;
                  
                  use DoctrineORMMapping as ORM;
                  
                  /**
                   * Project
                   *
                   * @ORMTable()
                   * @ORMEntity(repositoryClass="BakeryITBakeryBundleEntityProjectRepository")
                   */
                  class Project
                  {
                  /*
                  ..
                  */
                  }
                  

                  推荐答案

                  为了使用简短形式,您还需要提供包名称.这是根据供应商和捆绑包名称构造的.在你的情况下,它会是这样的:

                  In order to use the short form, you'll need to provide the bundle name too. This is constructed from the vendor and bundle name. In your case it would be something like:

                  from('BakeryITBakeryBundle:Project')
                  

                  有关捆绑包的更多信息,请参阅以下链接:

                  See the following link for more information on bundles:

                  http://symfony.com/doc/current/cookbook/bundles/best_practices.html

                  这篇关于Symfony2 Doctrine Custom Repository Class [Semantical Error] line 0, col 14 near 'Project p': Error: Class 'Project' is not defined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

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

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

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