我有一个数组,例如:
[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)
感谢您的帮助。
答案 0 :(得分:1)
$ key 和 $ values 是string参数,因此您可以将数组serialize()转换为字符串,然后再unserialize()
示例代码:
Configuration::updateValue('SELECTED_STATUSES', serialize($array));