I have drupal 7 site and I'm trying to listing all articles (with title) and where category field is empty (taxonomy). I'm running this code in my page with ->isNull and without, but not any results. Can someone explain what I'm doing wrong in here and why this is not working?
$query = db_select('node', 'n')
->fields('n', array('nid'))
->condition('n.type', 'article')
->condition('n.status', 1)
->isNull('n.field_tags')
->range(0, 10);
$results = $query->execute();
I'm get this error all the time:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'n.field_tags' in 'where clause': SELECT n.nid AS nid FROM {node} n WHERE (n.type = :db_condition_placeholder_0) AND (n.status = :db_condition_placeholder_1) AND (n.field_tags IS NULL ) LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => article [:db_condition_placeholder_1] => 1 ) in eval() (line 17 of /sites/site.com/modules/php/php.module(80) : eval()'d code).
->condition('n.field_tags', NULL)
or->condition('n.field_tags', [])
? Ah yeah, same, column not found...