国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Codeigniter PHP中將陣列儲存為JSON在資料庫中無法正常運(yùn)作
P粉012875927
P粉012875927 2024-04-02 00:08:37
0
1
608

我正在嘗試使用 codeigniter 網(wǎng)站將陣列作為 json 儲存在資料庫中,如下所示:

$this->db->insert('orders', 
                array('orderstatus' => $orderstatus,  
                      'productname' => json_encode($product1)
                    )
    );

數(shù)組的值如下:

Array
(
    [0] => Array
        (
            [id] => 8
            [productname] => Couple Combo Sherwani
            [pimage] => _RJ_0149-min.jpg,_RJ_0342-min.jpg,_RJ_0115-min.jpg
            [jrp] => 6000
            [deposit] => 6000
            [size] => XL
            [duration] => 3
            [quantity] => 1
        )

)

資料庫看起來像:

但是在資料庫中,該值儲存如下:

"Array"

誰能告訴我這裡出了什麼問題嗎,提前謝謝

P粉012875927
P粉012875927

全部回覆(1)
P粉848442185

對我來說它有效:

$products = [
    (object)[
        "name" => "Test product",
        "attribute1" => "Value1"
    ]
];

$this->db->table("orders")->insert([
    "name" => "Order for client",
    "info" => "Client want this order today",
    "products" => json_encode($products)
]); //In products column i have [{"name":"Test product","attribute1":"Value1"}]
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板