Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 contents 表为空时,checkField 报错 #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

w-sx
Copy link

@w-sx w-sx commented Apr 10, 2024

触发条件

当数据库中 contents 表为空时,也即博客中无文章。

访问首页引发 functions.php 中 checkField 函数报错

array_key_exists(): Argument #2 ($array) must be of type array, null given

错误原因

由于 contents 表中没有数据。

functions.php 中 checkField 函数的判断字段是否存在语句。

$db->fetchRow($db->select()->from('table.contents')) 返回了一个 null

array_key_exists() 函数的第二个参数接受 null 后报错。

解决方法

重写字段是否存在的判断逻辑。

@changbin1997
Copy link
Owner

非常感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants