IDIORM: Unable to extract data from mysql / php (very simple but too complicated for a newbie)

I'm trying to extract data from column 'field_data' in table tk_custom_data WHERE:

  1. 'product_id' in table 'tk_custom_data' matches 'id' in other table called 'tk_product' and
  2. 'field_id' in table 'tk_custom_data' is equal to "21"

Result should be extracted when using $main_result

But this is simply too complicated for me, I'm still a total newbie. Please help :( Using IDIORM ORM

$product_id = ORM::for_table($config['db']['pre'].'product')->find_one($_GET['id']);
$item_id = $product_id['id'];
$value = '21'; 

$result = ORM::for_table($config['db']['pre'].'custom_data')
    ->where('product_id',$item_id)
    ->where('field_id',$value)
    ->find_one();   

foreach ($result as $info) { 
    $main_result = $info['field_data']; 
}

Upvotes: 0

Views: 65

Answers (0)

Related Questions