我试图运行以下查询来访问我的WP cf7dbplugin\\u submitted表,但它一直是空的。我已将我的表添加到wp db中。php模型本身:
Added the contact form table- cf7dbplugin_submits to the following at about line 268:
var $tables = array(\'cf7dbplugin_submits\',\'posts\', . . .)
At around line 304 add the following:
/**
* WordPress cf7dbplugin_submits table
*/
public $cf7dbplugin_submits;
因此,数据库函数应该可以找到它(在代码的其他地方使用时)。但对于任何$postid,以下内容始终是空的:
function action_getpost($postid) {
global $wpdb, $out;
$out[\'post\'] = array();
$out[\'uploads\'] = array();
// wp_posts has one row for each submitted form.
// wp_nf_objectmeta includes a set of rows for each defined form.
$query =
"SELECT submit_time, form_name, field_value" .
"FROM $wpdb->cf7dbplugin_submits " .
"WHERE field_order = %d AND submit_time = %d ";
$queryp = $wpdb->prepare($query, array(9999, $postid));
if (empty($queryp)) {
$out[\'errmsg\'] = "Internal error: \\"$query\\" \\"$postid\\"";
return;
}
$wpdb->show_errors( true );
$row = $wpdb->get_row($queryp, ARRAY_A);
if (empty($row)) {
$out[\'errmsg\'] = "No rows matching: \\"$postid\\"";
return;
}
如果我只是在phpMyAdmin中运行以下查询,其中$postid=1445125066.4375:
SELECT submit_time, form_name, field_value
FROM wp_cf7dbplugin_submits
WHERE field_order = 9999 AND submit_time = 1445125066.4375
它生成所需的行
submit_time form_name field_value
1445125066.4375 Demographics usernamehere
那么,为什么函数返回我的错误,即没有与1445125066.4375匹配的行?有什么想法吗?