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

<small id='6KUiR'></small><noframes id='6KUiR'>

    • <bdo id='6KUiR'></bdo><ul id='6KUiR'></ul>
    <tfoot id='6KUiR'></tfoot>

        <legend id='6KUiR'><style id='6KUiR'><dir id='6KUiR'><q id='6KUiR'></q></dir></style></legend>

      1. Symfony2 Doctrine CAST AS DECIMAL

        Symfony2 Doctrine CAST AS DECIMAL(Symfony2 Doctrine CAST AS DECIMAL)
          <bdo id='qpguX'></bdo><ul id='qpguX'></ul>
        • <small id='qpguX'></small><noframes id='qpguX'>

        • <tfoot id='qpguX'></tfoot><legend id='qpguX'><style id='qpguX'><dir id='qpguX'><q id='qpguX'></q></dir></style></legend>

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

                    <tbody id='qpguX'></tbody>

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

                  问题描述

                  我在 Symfony2 中使用 Sonata Admin Bundle 并有一个自定义过滤器.在数据库中,列是浮动的(无法更改).如果你输入 1333.33 将没有结果.

                  I use Sonata Admin Bundle in Symfony2 and have a custom filter. In database, column is float (cannot change it). If you type 1333.33 there will be no result.

                  一种解决方案是使用 CAST:

                  One solution is to use CAST:

                  CAST( o.price AS DECIMAL) = CAST( 399.99 AS DECIMAL)
                  

                  查询在 SQL 中运行良好,但 Doctrine 抛出错误.所以我的问题是如何在 Doctrine 或其他可靠的解决方案中使用 CAST?

                  Query is working just fine in SQL but Doctrine throws an error. So my question is how can use CAST in Doctrine or another reliable solution?

                  推荐答案

                  Doctrine 在其 DQL 中没有提供 CAST 构造(参见 这个列表).

                  Doctrine does not provide a CAST construct in its DQL (see this list).

                  但对于您的特殊情况,比较乘以 100 的值应该足够了:

                  But for your special case, it should be enough to compare the values multiplyed by 100:

                  o.price * 100 = 399.99 * 100
                  

                  这篇关于Symfony2 Doctrine CAST AS DECIMAL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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(教义和未更新的关系)
                      • <bdo id='iStKg'></bdo><ul id='iStKg'></ul>

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

                        2. <legend id='iStKg'><style id='iStKg'><dir id='iStKg'><q id='iStKg'></q></dir></style></legend>

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

                            <tbody id='iStKg'></tbody>
                          • <tfoot id='iStKg'></tfoot>