繁体   English   中英

如何在 Prestashop 1.6 中将数组值保存为配置值

[英]How to save array value as configuration value in Prestashop 1.6

我有一个数组,例如:

[0] => Array
    (
      [id_order_state] => 2
      [name] => Text
    )

我想使用此代码保存此值,但我不能。

Configuration::updateValue('SELECTED_STATUSES', $array);

在 /classes/Configuration.php 我有关于这个的更多信息:

/**
     * Update configuration key and value into database (automatically insert if key does not exist)
     *
     * Values are inserted/updated directly using SQL, because using (Configuration) ObjectModel
     * may not insert values correctly (for example, HTML is escaped, when it should not be).
     * @TODO Fix saving HTML values in Configuration model
     *
     * @param string $key Key
     * @param mixed $values $values is an array if the configuration is multilingual, a single string else.
     * @param bool $html Specify if html is authorized in value
     * @param int $id_shop_group
     * @param int $id_shop
     * @return bool Update result
     */
    public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)

感谢您的帮助。

$key$values字符串参数,因此您可以将数组序列化()为字符串,然后再将其反序列化()

示例代码:

Configuration::updateValue('SELECTED_STATUSES', serialize($array));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM