ZBlog插件LayCenter用户中心关闭后,在原始后台发布文章提示“Field ‘log_LayCenter_BuyContent’ doesn’t have a default value”问题的解决方法

用户头像 ZBlog 51 次阅读 发布于 20 天前


问题

ZBlog插件LayCenter用户中心关闭后,在原始后台发布文章提示“Field 'log_LayCenter_BuyContent' doesn't have a default value”,导致无法发布文章。

解决方法

问题分析

因为LayCenter插件在post表中增加了几个longtext类型的字段,但mysql无法为longtext类型的字段配置默认值,所以在LayCenter禁用后,zblog向数据库插入数据时没有提供这些字段数据,导致无法正常插入到数据库。

两种解决方法

1、如果以后不打算使用LayCenter,可在LayCenter配置中的其他配置页面中,勾选“卸载清空数据”,然后停用LayCenter即可删除post中新增的字段。(注意:这一操作会删除所有LayCenter所有相关数据,如果仅是临时停用,请使用下一方法)

2、在主题或任意插件的include.php文件结尾中增加以下代码:

 

 PHP
$zbp->datainfo['Post'] = array_merge($zbp->datainfo['Post'], array(
    'LayCenter_BuyContent'     => array('log_LayCenter_BuyContent', 'string', '', ''),
    'LayCenter_VipContent'     => array('log_LayCenter_VipContent', 'string', '', ''),
    'LayCenter_LoginContent'   => array('log_LayCenter_LoginContent', 'string', '', ''),
    'LayCenter_SendContent'    => array('log_LayCenter_SendContent', 'string', '', ''),
));

 

如果文件结尾是?>代码,那么需要放在该代码的上一行。

如果重新启用了LayCenter,需要删掉这些增加的代码。