• <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()

        时间:2024-08-09
      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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Symfony Cache 学说/orm/Proxies 未能在第 209 行打开流/Proxy/AbstractPro 下一篇:如果第二个查询不起作用,则删除或撤消第一个查询

                  相关文章

                  <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>

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