运行此查询时,始终为数据库错误创建日志。当表存在时,它可以正常工作,但当它不存在时,它会生成如下所示的调试日志。
有没有其他方法可以检查数据库表是否存在,或者通过填充调试日志文件来避免这些错误?
if($wpdb->get_var("SHOW TABLES LIKE \'$table_name\'") != $table_name) {
// do something
}
调试日志:
[09-Sep-2018 12:21:50 UTC] WordPress database error Table \'splivemain_db.wp_survey_popup_form\' doesn\'t exist for query DESCRIBE wp_survey_popup_form; made by do_action(\'omxl-logger_page_omxl-cf7\'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, myplugin__Logger->display, myplugin__Logger->get_columns
[09-Sep-2018 12:21:50 UTC] WordPress database error Table \'splivemain_db.wp_survey_popup_form\' doesn\'t exist for query DESCRIBE wp_survey_popup_form; made by do_action(\'omxl-logger_page_omxl-cf7\'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, myplugin__Logger->display, myplugin__Logger->get, myplugin__Logger->get_columns
[09-Sep-2018 12:21:50 UTC] WordPress database error Table \'splivemain_db.wp_survey_popup_form\' doesn\'t exist for query SELECT* FROM wp_survey_popup_form WHERE 1=1 ORDER BY activity_date DESC LIMIT 0, 10 made by do_action(\'omxl-logger_page_omxl-cf7\'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, myplugin__Logger->display, myplugin__Logger->get