<bdo id='M4ZBY'></bdo><ul id='M4ZBY'></ul>

  1. <legend id='M4ZBY'><style id='M4ZBY'><dir id='M4ZBY'><q id='M4ZBY'></q></dir></style></legend>

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

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

      原则 2:使用查询生成器更新查询

      Doctrine 2: Update query with query builder(原则 2:使用查询生成器更新查询)
            <tbody id='fTvmu'></tbody>

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

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

              • <bdo id='fTvmu'></bdo><ul id='fTvmu'></ul>
                <tfoot id='fTvmu'></tfoot>

              • <legend id='fTvmu'><style id='fTvmu'><dir id='fTvmu'><q id='fTvmu'></q></dir></style></legend>
                本文介绍了原则 2:使用查询生成器更新查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                嗨我有以下查询,但它似乎不起作用.

                Hi I've got the following query but it doesn't seem to work.

                $q = $this->em->createQueryBuilder()
                    ->update('modelsUser', 'u')
                    ->set('u.username', $username)
                    ->set('u.email', $email)
                    ->where('u.id = ?1')
                    ->setParameter(1, $editId)
                    ->getQuery();
                $p = $q->execute();
                

                这将返回以下错误消息:

                This returns the following error message:

                致命错误:未捕获的异常'教义ORM查询查询异常'带有消息'[语义错误]行0, col 38 靠近 'testusername WHERE':错误:未定义testusername".在...

                Fatal error: Uncaught exception 'DoctrineORMQueryQueryException' with message '[Semantical Error] line 0, col 38 near 'testusername WHERE': Error: 'testusername' is not defined.' in ...

                我会很高兴得到任何帮助

                I would be glad of any help

                推荐答案

                我觉得你需要使用 ->set() 让你的所有 values 参数都更安全:

                I think you need to use ->set() It's much safer to make all your values parameters:

                $queryBuilder = $this->em->createQueryBuilder();
                $query = $queryBuilder->update('modelsUser', 'u')
                        ->set('u.username', ':userName')
                        ->set('u.email', ':email')
                        ->where('u.id = :editId')
                        ->setParameter('userName', $userName)
                        ->setParameter('email', $email)
                        ->setParameter('editId', $editId)
                        ->getQuery();
                $result = $query->execute();
                

                这篇关于原则 2:使用查询生成器更新查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                Doctrine 2, query inside entities(原则 2,实体内部查询)
                Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                Doctrine and unrefreshed relationships(教义和未更新的关系)
                <tfoot id='i81XU'></tfoot>
                  <tbody id='i81XU'></tbody>
                  <bdo id='i81XU'></bdo><ul id='i81XU'></ul>

                  1. <legend id='i81XU'><style id='i81XU'><dir id='i81XU'><q id='i81XU'></q></dir></style></legend>

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