小编典典

使用Microsoft SQL查询反序列化PHP

sql

我试图将数据从mySQL数据库导入Microsoft SQL,因为我们公司使用mySQL网站和MS-SQL Accounting / ERP系统。

无论如何… mySQL中的某些字段已“序列化”。我正在尝试确定如何使用确定的SQL代码来反序列化并将数据读入MS SQL。这可能吗?

其中一个字段如下所示:

a: 9: {
    s: 15: "product_options";
    a: 2: {
        i: 719;
        s: 4: "2979";
        i: 718;
        s: 4: "2975";
    }
    s: 18: "unlimited_download";
    s: 1: "N";
    s: 7: "product";
    s: 37: "Champion Tagless Ringer Tee - T-Shirt";
    s: 10: "company_id";
    i: 0;
    s: 6: "is_edp";
    s: 1: "N";
    s: 12: "edp_shipping";
    s: 1: "N";
    s: 10: "base_price";
    d: 9.9900000000000002131628207280300557613372802734375;
    s: 12: "stored_price";
    s: 1: "N";
    s: 21: "product_options_value";
    a: 2: {
        i: 0;
        a: 13: {
            s: 9: "option_id";
            s: 3: "719";
            s: 11: "option_type";
            s: 1: "S";
            s: 9: "inventory";
            s: 1: "Y";
            s: 11: "option_name";
            s: 5: "Color";
            s: 11: "option_text";
            s: 0: "";
            s: 11: "description";
            s: 0: "";
            s: 10: "inner_hint";
            s: 0: "";
            s: 17: "incorrect_message";
            s: 0: "";
            s: 8: "modifier";
            s: 5: "0.000";
            s: 13: "modifier_type";
            s: 1: "A";
            s: 8: "position";
            s: 2: "30";
            s: 12: "variant_name";
            s: 13: "White/Scarlet";
            s: 5: "value";
            s: 4: "2979";
        }
        i: 1;
        a: 13: {
            s: 9: "option_id";
            s: 3: "718";
            s: 11: "option_type";
            s: 1: "S";
            s: 9: "inventory";
            s: 1: "Y";
            s: 11: "option_name";
            s: 13: "Clothing Size";
            s: 11: "option_text";
            s: 0: "";
            s: 11: "description";
            s: 0: "";
            s: 10: "inner_hint";
            s: 0: "";
            s: 17: "incorrect_message";
            s: 0: "";
            s: 8: "modifier";
            s: 5: "0.000";
            s: 13: "modifier_type";
            s: 1: "A";
            s: 8: "position";
            s: 2: "20";
            s: 12: "variant_name";
            s: 6: "Medium";
            s: 5: "value";
            s: 4: "2975";
        }
    }
}

在此先感谢您提供任何帮助。


阅读 242

收藏
2021-05-16

共1个答案

小编典典

我知道这一点,但是仅在Microsoft SQL代码中使用的是序列化和反序列化的吗?

我相当确定unserialize()在MS SQL中没有直接等效于PHP的PHP 。

您必须自己构建它-尝试让PHP处理它会更好。

2021-05-16