Get entry id from post id

Hi,

I’m trying to do the opposite of the SQL query here. I want to get the Post ID from the Entry ID. So I want to reverse the select to “where entry id = X.”

I’ve tried it using the below but didn’t work.

$entry_post_id = $frmdb->get_var(“SELECT post_id FROM $frmdb->entries WHERE id=’”. $id .”‘”)

I also tried using wpdb query on the frm_items table as below but didn’t work. Tried also with my dbase prefix to the name but didn’t work.

SELECT post_id FROM $wpdb->frm_items WHERE id=’”. $id .”‘

Now I’m at a direct SQL query from the page, which does work as below.

$result = mysql_query(“SELECT post_id FROM nh_frm_items WHERE id = ‘X’”)

But would like to use the frmdb if possible. Also would like to understand how the frmdb works – not documented really…

Thanks in advance for all your recent help!

This should work fine:

global $frmdb;
$entry_post_id = $frmdb->get_var("SELECT post_id FROM $frmdb->entries WHERE id=5");

Topic closed.