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

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

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

          <bdo id='nwr4F'></bdo><ul id='nwr4F'></ul>
      1. 如何将 Laravel Query Builder 结果作为整数获取

        时间:2023-09-23
      2. <i id='53TCP'><tr id='53TCP'><dt id='53TCP'><q id='53TCP'><span id='53TCP'><b id='53TCP'><form id='53TCP'><ins id='53TCP'></ins><ul id='53TCP'></ul><sub id='53TCP'></sub></form><legend id='53TCP'></legend><bdo id='53TCP'><pre id='53TCP'><center id='53TCP'></center></pre></bdo></b><th id='53TCP'></th></span></q></dt></tr></i><div id='53TCP'><tfoot id='53TCP'></tfoot><dl id='53TCP'><fieldset id='53TCP'></fieldset></dl></div>

          <small id='53TCP'></small><noframes id='53TCP'>

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

                  <tbody id='53TCP'></tbody>

                <tfoot id='53TCP'></tfoot>
                  <bdo id='53TCP'></bdo><ul id='53TCP'></ul>
                  本文介绍了如何将 Laravel Query Builder 结果作为整数获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我使用 Laravel Query Builder 查询 MySQL 数据库,但它返回整数值作为字符串值.

                  I'm using Laravel Query Builder to query MySQL database but it returns integer values as string values.

                  我有以下查询.

                  $query = DB::table('store_products')->select('products.id', 'products.name', 'products.unit_type', 'products.price', 'products.image_path', 'products.is_popular', 'store_products.price AS store_price')
                             ->join('products', 'products.id', '=', 'store_products.product_id')
                             ->join('product_categories', 'product_categories.product_id', '=', 'store_products.product_id')
                             ->where('store_products.store_id', $store_id)
                             ->where('store_products.product_id', $product_id);
                  

                  此处查询获取存在于 Store_Products 中的 Product,用于给定 store_id.

                  Here the query gets Product which is existing in Store_Products for given store_id.

                  问题是,当我使用查询生成器时,它返回 id(这是产品的主键)作为 string.演员表好像有问题.

                  The problem is, it returns id (which is the Primary Key for Product) as string when I use Query Builder. Looks like there is something wrong with casts.

                  我该如何解决这个问题?

                  How can I solve this problem?

                  非常感谢您.

                  推荐答案

                  强制转换不是解决方案,而是解决问题的方法.您的实际问题是缺少 mysqlnd 插件.

                  Casting is not a solution but a workaround to the problem. Your actual problem is missing mysqlnd plugin.

                  检查mysqlnd是否像这样安装

                  $ sudo dpkg -l | grep 'mysqlnd'
                  

                  如果没有安装,你需要像这样安装(假设你有php5)

                  If it's not installed, you need to install it like so (assuming you have php5)

                  $ sudo apt-get install php5-mysqlnd
                  

                  这些命令适用于 ubuntu.如果您还有其他东西,只需将它们转换为您合适的操作系统即可.

                  These commands are for ubuntu. If you have something else, just convert them to your appropriate OS.

                  这篇关于如何将 Laravel Query Builder 结果作为整数获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:模型中的 Laravel 动态可填充 下一篇:Laravel 不同计数

                  相关文章

                  最新文章

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

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

                  2. <small id='DNOal'></small><noframes id='DNOal'>

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