0

i have this query on drupal 6

$catq=' ( SELECT term_node.nid as node_id FROM {term_node} WHERE tid='.$catint.') as cat, '

i have upgrade it like this

$query=db_select('term_node');
                    ->addfield('term_node', 'nid', 'node');
                    ->field('term_node', 'node' ); 
                    ->condition('term_node.tid', = , $catint);
                $cat=$query->addfield($query, 'cat');

is it wrong?

apaderno
  • 28,547
  • 16
  • 75
  • 90
Dewitt
  • 1
  • 1

1 Answers1

0

You are doing it wrong. The right syntax for query - keeping your data will be:

$query = db_select('term_node', 't')
            ->fields('t')
            ->condition('term_node.tid', $catint, '=')
            ->execute();
          $logo = $query->fetchAll();

But in drupal 7 there is no table term_node, probably you need 'taxonomy_index'.

hugronaphor
  • 948
  • 8
  • 23
  • But with field('t') i do a select of all field of the table, i need only term_node.nid, and for set the aliases of the all query? I have this table because we have develop a new database =) P.S. thanks for help! =) – Dewitt Mar 10 '14 at 08:58
  • P.P.S. is recursive, i recall $catq in another query in the file – Dewitt Mar 10 '14 at 09:32