参数必须是在phpmyadmin中实现Countable的数组或对象

Lee*_*Lee 14 sql wordpress

当我尝试在phpmyadmin中查看wp_posts表时,我看到此错误消息,但不知道它的含义并且以前从未见过它.

有人可以帮助我尝试以某种方式摆脱这个吗?

Warning in ./libraries/sql.lib.php#613
count(): Parameter must be an array or an object that implements Countable

Backtrace

./libraries/sql.lib.php#2128: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#2079: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'afterhours',
string 'wp_posts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/original/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `wp_posts`',
NULL,
NULL,
)
./sql.php#221: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'afterhours',
string 'wp_posts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/original/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `wp_posts`',
NULL,
NULL,
)
Run Code Online (Sandbox Code Playgroud)

A. *_*ray 19

这似乎是phpmyadmin的重复- count():参数必须是数组或实现Countable的对象

根据链接帖子的最佳答案,看起来./libraries/sql.lib.php中可能存在错误导致代码尝试对除数组之外的其他内容的count()函数(或实现"可数"的对象.修复它(根据链接的响应):

编辑文件'/usr/share/phpmyadmin/libraries/sql.lib.php'并替换

(count($analyzed_sql_results['select_expr'] == 1) 
Run Code Online (Sandbox Code Playgroud)

附:

(count($analyzed_sql_results['select_expr']) == 1
Run Code Online (Sandbox Code Playgroud)

这是因为:

  • count不能在非数组上执行(因此你的错误,"参数必须是数组或实现Countable的对象")
  • count()中的"== 1"是等价测试,而不是数组
  • 从count()中删除"== 1"会产生一个count(数组)函数.


小智 12

我通过使用 is_array() 函数验证它是否真的是一个数组来解决这个问题,如下所示:

if (is_array($yourArray)) {
    //Your count()
}
Run Code Online (Sandbox Code Playgroud)