如何在 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 是 string parameters so you can serialize() the array to a string then unserialize() 它稍后
示例代码:
Configuration::updateValue('SELECTED_STATUSES', serialize($array));
我有一个数组,例如:
[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 是 string parameters so you can serialize() the array to a string then unserialize() 它稍后
示例代码:
Configuration::updateValue('SELECTED_STATUSES', serialize($array));