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

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

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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