更新 WP 数据库序列化选项的问题

我很困惑,因为我无法使用以下内容更新“active_plugins”序列化字段:
UPDATE wp_options SET option_value='a:2:{i:0;s:19:"akismet/akismet.php";i:1;s:21:"hello-dolly/hello.php";}' WHERE option_name='active_plugins'
如您所见,我试图在 WP 安装时使用“active_plugins”字段中最初包含的相同数据更改该字段... mysql 错误显然是由于该字段中的分号(当我将它们取出时,-尽管有序列化数据值,ogf当然...... - 查询成功运行!
任何线索?

蓝山帝景
浏览 184回答 2
2回答

慕码人2483693

由于序列化数组,我可能会在 PHP 中这样做。你应该做一个这样的函数:function update_my_plugins() {$option = get_option('active_plugins'); // This will return you an array see below$new_array = [    'something here',    'another something'];update_option('active_plugins', $new_array); // This will automatically reserialize}从那里,只需将此函数放入您的 footer.php 并访问您的站点。当您访问您的网站时它会触发,然后您可以将其取出。

Smart猫小萌

还是不行!!!当我在 PHPMyAdmin 中运行查询时,下面显示了一个错误,我不明白为什么(它还在我的 PHP 脚本中返回一个错误......:UPDATE    wor1865_optionsSET    option_value = 'a:2:{i:0;s:19:"akismet/akismet.php";i:1;s:21:"hello-dolly/hello.php";}'WHERE    option_name = 'active_plugins'
打开App,查看更多内容
随时随地看视频慕课网APP