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

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

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

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

        • <bdo id='H3X1M'></bdo><ul id='H3X1M'></ul>

        具有数组值的 Doctrine DBAL setParameter()

        Doctrine DBAL setParameter() with array value(具有数组值的 Doctrine DBAL setParameter())
      1. <tfoot id='nDWFX'></tfoot>
        <i id='nDWFX'><tr id='nDWFX'><dt id='nDWFX'><q id='nDWFX'><span id='nDWFX'><b id='nDWFX'><form id='nDWFX'><ins id='nDWFX'></ins><ul id='nDWFX'></ul><sub id='nDWFX'></sub></form><legend id='nDWFX'></legend><bdo id='nDWFX'><pre id='nDWFX'><center id='nDWFX'></center></pre></bdo></b><th id='nDWFX'></th></span></q></dt></tr></i><div id='nDWFX'><tfoot id='nDWFX'></tfoot><dl id='nDWFX'><fieldset id='nDWFX'></fieldset></dl></div>

          <legend id='nDWFX'><style id='nDWFX'><dir id='nDWFX'><q id='nDWFX'></q></dir></style></legend>
            <bdo id='nDWFX'></bdo><ul id='nDWFX'></ul>
                <tbody id='nDWFX'></tbody>

                1. <small id='nDWFX'></small><noframes id='nDWFX'>

                  本文介绍了具有数组值的 Doctrine DBAL setParameter()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用学说 DBAL,但由于 queryBuilder 的结果,SQL 查询出现了一些问题.

                  I'm using doctrine DBAL and have some problem with SQL query as result of a queryBuilder.

                  $builder = $this->getConnection()->getQueryBuilder();
                  $builder->select(['id','name','type'])
                           ->from('table')
                           ->where('id='.(int)$value)
                           ->setMaxResults(1);
                  $builder->andWhere($builder->expr()->in('type', ['first','second']));
                  
                  echo(builder->getSQL());
                  
                  $data = $builder->execute()->fetchRow();
                  

                  并获取 SQL

                  SELECT id, name, type FROM table WHERE (id=149) AND (type IN (first,second)) LIMIT 1
                  

                  这就是问题所在,我需要将 (type IN (first,second)) 编码为字符串,例如 (type IN ('first','second'))

                  And this is the problem, I need that (type IN (first,second)) was encoded as strings like (type IN ('first','second'))

                  如何以正确的方式使用查询生成器做到这一点?

                  How to do that with query builder in the right way?

                  推荐答案

                  试试

                  $builder->andWhere('type IN (:string)');
                  $builder->setParameter('string', array('first','second'), DoctrineDBALConnection::PARAM_STR_ARRAY);
                  

                  这篇关于具有数组值的 Doctrine DBAL setParameter()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='htTy4'></tfoot>

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

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

                          <tbody id='htTy4'></tbody>

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