Posts

Showing posts from February, 2022

Search Drupal Nodes and Comments with Code

<? $revisions = db_select('field_revision_body', 'r')     ->distinct()     ->fields('r', array('entity_id'))     ->condition('r.body_value', '%' . db_like('www') . '%', 'LIKE')     ->execute(); // Avoiding unions for short queries foreach ($revisions as $revision) { $nodes = db_select('node', 'n')     ->fields('n', array('uid'))     ->condition('nid', $revision->entity_id,'=')     ->execute(); foreach ($nodes as $node) if ($node->uid != 1)     echo '<a target="_blank" href="/node/'.$revision->entity_id.'">node '.$revision->entity_id.'</a><br>'; } ?> <!-- The above node search code will also return nodes where previous versions have the string Clean-up revisions first if necessary.  Code for searching through comments given below -->  <? // Identical code from