<bdo id='5aYBz'></bdo><ul id='5aYBz'></ul>

    <small id='5aYBz'></small><noframes id='5aYBz'>

    <tfoot id='5aYBz'></tfoot>

    <legend id='5aYBz'><style id='5aYBz'><dir id='5aYBz'><q id='5aYBz'></q></dir></style></legend>
    1. <i id='5aYBz'><tr id='5aYBz'><dt id='5aYBz'><q id='5aYBz'><span id='5aYBz'><b id='5aYBz'><form id='5aYBz'><ins id='5aYBz'></ins><ul id='5aYBz'></ul><sub id='5aYBz'></sub></form><legend id='5aYBz'></legend><bdo id='5aYBz'><pre id='5aYBz'><center id='5aYBz'></center></pre></bdo></b><th id='5aYBz'></th></span></q></dt></tr></i><div id='5aYBz'><tfoot id='5aYBz'></tfoot><dl id='5aYBz'><fieldset id='5aYBz'></fieldset></dl></div>
    2. Yii2 获取以逗号分隔的产品 ID

      Yii2 get product id seperated by comma(Yii2 获取以逗号分隔的产品 ID)
      <i id='4iPLf'><tr id='4iPLf'><dt id='4iPLf'><q id='4iPLf'><span id='4iPLf'><b id='4iPLf'><form id='4iPLf'><ins id='4iPLf'></ins><ul id='4iPLf'></ul><sub id='4iPLf'></sub></form><legend id='4iPLf'></legend><bdo id='4iPLf'><pre id='4iPLf'><center id='4iPLf'></center></pre></bdo></b><th id='4iPLf'></th></span></q></dt></tr></i><div id='4iPLf'><tfoot id='4iPLf'></tfoot><dl id='4iPLf'><fieldset id='4iPLf'></fieldset></dl></div>
          <legend id='4iPLf'><style id='4iPLf'><dir id='4iPLf'><q id='4iPLf'></q></dir></style></legend>
            <tbody id='4iPLf'></tbody>
            <bdo id='4iPLf'></bdo><ul id='4iPLf'></ul>

          • <tfoot id='4iPLf'></tfoot>

                <small id='4iPLf'></small><noframes id='4iPLf'>

                本文介绍了Yii2 获取以逗号分隔的产品 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我已经关注了这个人的教程

                I have followed this guy tutorial

                并获得所有产品的总价,现在我创建了一个名为 order 的表,其中包含(total_price 和 product)列
                现在我想要选择(添加到购物车)的所有产品 ID 用逗号分隔并保存到

                and got total price of all products and now I have created a table called order which contains (total_price and product) columns
                now I want what all products ID which are selected (added to cart) separated by comma and be saved into

                $model= new orders ()
                $model->product (product id added in cart separated by comma)in db
                

                我已经通过控制器将 total_price 保存在数据库中.

                I've saved total_price in db through controller though.

                提前致谢

                推荐答案

                使用 PHP implode() 和 explode() 函数来保存逗号分隔的数据在数据库中

                Use PHP implode() and explode() function to save comma seprated data in DB

                implode() 函数返回一个字符串,其中包含以相同顺序表示的所有数组元素的字符串

                implode() function returns a string containing a string representation of all the array elements in the same order

                $model= new orders ();
                $array = [1, 2, 3, 4, 5];
                $model->product = implode(', ', $array);
                $model->save();
                

                explode() 函数返回一个字符串数组.

                explode() function returns an array of strings.

                $string = "1, 2, 3, 4, 5";
                explode(', ', $string);
                

                这篇关于Yii2 获取以逗号分隔的产品 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                Joomla include database functions(Joomla 包含数据库功能)
                nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)

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

                    <tfoot id='Au1Iw'></tfoot>
                      <bdo id='Au1Iw'></bdo><ul id='Au1Iw'></ul>
                      1. <small id='Au1Iw'></small><noframes id='Au1Iw'>

                        <legend id='Au1Iw'><style id='Au1Iw'><dir id='Au1Iw'><q id='Au1Iw'></q></dir></style></legend>
                            <tbody id='Au1Iw'></tbody>