php - WordPress 插件数据库错误 您的 SQL 语法有错误

标签 php mysql database wordpress

每次加载页面时我都会多次收到此消息。 [07-Jul-2018 17:30:49 UTC] WordPress 数据库错误 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 6 行的 'AND p.post_status='publish'' 附近用于查询 SELECT count(*) FROM wp_posts p

的正确语法
    [07-Jul-2018 17:30:49 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND p.post_status='publish'' at line 6 for query SELECT count(*) FROM wp_posts p
INNER JOIN wp_term_relationships tr ON tr.object_id = p.ID
INNER JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN wp_geo_mashup_location_relationships gmlr ON gmlr.object_id = p.ID AND gmlr.object_name = 'post'
WHERE tt.term_id =
AND p.post_status='publish' made by require('wp-blog-header.php'),
require_once('wp-includes/template-loader.php'),
include('/themes/hestia-child/front-page.php'),
get_footer, locate_template, load_template,
require_once('/themes/hestia-child/footer.php'),
do_action('hestia_do_footer_child'),
WP_Hook->do_action, WP_Hook->apply_filters,
call_user_func_array, hestia_the_footer_content_child,
dynamic_sidebar, call_user_func_array, WP_Widget->display_callback,
WP_Widget_Categories->widget, wp_dropdown_categories,
walk_category_dropdown_tree, call_user_func_array, Walker->walk, Walker->display_element,
call_user_func_array, Walker_CategoryDropdown->start_el, apply_filters('list_cats'),
WP_Hook->apply_filters, call_user_func_array, GeoMashup::list_cats, GeoMashupDB::category_located_post_count

我认为它会导致 GeoMashup 的“geo-mashup-db.php”的一部分(复制如下),并且我已经阅读了一些有关 ID/id 之间的大写/小写不匹配的内容,这可能会导致此问题,但我可以似乎没有找到任何这样的例子。任何帮助或建议都会很棒。

* Get the number of located posts in a category.
*
* @since 1.2
*
* @param id $category_id
* @return int
*/
public static function category_located_post_count( $category_id ) {
global $wpdb;

$select_string = "SELECT count(*) FROM {$wpdb->posts} p
INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.ID
INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN {$wpdb->prefix}geo_mashup_location_relationships gmlr ON gmlr.object_id = p.ID AND gmlr.object_name = 'post'
WHERE tt.term_id = " . esc_sql( $category_id ) ."
AND p.post_status='publish'";
return $wpdb->get_var( $select_string );
}

/**
* Get categories that contain located objects.
*
* Not sufficient - probably want parent categories.
*
* @return array Located category id, name, slug, description, and parent id
*/
private static function get_located_categories() {
global $wpdb;

$select_string = "SELECT DISTINCT t.term_id, t.name, t.slug, tt.description, tt.parent
FROM {$wpdb->prefix}geo_mashup_location_relationships gmlr
INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id = gmlr.object_id
INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id
WHERE tt.taxonomy='category'
ORDER BY t.slug ASC";
return $wpdb->get_results( $select_string );
}

最佳答案

一篇较旧的文章,但就其值(value)而言:问题在于 Geo Mashup 的小部件选项,该选项“自动”为类别创建 map 链接(管理 >“模糊设置”)。

所有类别中的所有帖子都必须保存所有 GeoMeta(lat、lnggeo-address ,以及保存的名称),否则您会经常收到此错误。

取消选中将 map 链接添加到类别列表将停止错误。
按名称/ID 映射类别的短代码和模板标签仍然可以正常工作。

希望这可以帮助别人。

关于php - WordPress 插件数据库错误 您的 SQL 语法有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51227248/

相关文章:

php - 如何将日期和时间转换为存储在 mysql datetime 中

php - 如何检查用户是否登录?

php - Paypal (IPN) MySQL 查询调整

php - 生成 CSV 时更改值

mysql - MySQL 中的自动 TRUNCATE 表

php - 如何使用ID从关联表中获取值?

php - 在 TYPO3 Extbase 中使用自定义查询更新表

database - Golang gorm mock

java - 如何修复此错误 : Parameter index out of range

javascript - 从产品 View 中删除字符 "$"