doutan3192 2017-06-11 06:45
浏览 17

Codeigniter - 在单个mysql列中可能存在多维数组数据?

Multidimensional array data store inside a single mysql column.

Here it is my data. How to store it inside a single mysql column?

Someone tell me the solution with example code.

$data = array(
        '2017' => array(
            '6' => array(
                '10' => array(
                    'count' => 76
                ),
                '11' => array(
                    'count' => 42
                ),
                '15' => array(
                    'count' => 23
                ),
            ),
            '7' => array(
                '5' => array(
                    'count' => 26
                ),
                '25' => array(
                    'count' => 82
                ),
                '26' => array(
                    'count' => 53
                ),
            ),
        ),
        '2018' => array(
            '6' => array(
                '18' => array(
                    'count' => 30
                )
            )
        ),
    );
  • 写回答

3条回答 默认 最新

  • duanchu7271 2017-06-11 07:09
    关注

    Have your column to type text for longer data. then use

    $data = json_encode($data);
    

    then store that $data.

    Later, to get it. just use decode:

    $data = json_decode($data); // Alternately json_decode($data,true);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端