get_row returns empty when data exists
I am trying to run the following query to access my WP cf7dbplugin_submits table but it keeps coming up empty. I have added my table into wp-db.php model as such:
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;
So the database function should find it (it has when used elsewhere in my code). But the following is consistently coming up empty for any $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;
}
If I just run the following query in phpMyAdmin, where $postid = 1445125066.4375:
SELECT submit_time, form_name, field_value
FROM wp_cf7dbplugin_submits
WHERE field_order = 9999 AND submit_time = 1445125066.4375
It produces the needed row
submit_time form_name field_value
1445125066.4375 Demographics usernamehere
So why is the function returning my error of no rows matching 1445125066.4375? Any ideas?
Topic get-row plugin-contact-form-7 wpdb Wordpress
Category Web