0

We are trying to search all text_long or text_with_summary fields for all content type nodes. I can do it for the field_data_body. I need to expand this for all content types using text_long and text_with_summary. I would like to iterate all nodes for all content types and select all fields in the node with the text_long and text_with_summary field type.

Here is what I use for selecting just the body. I use a cursor to search each db which is why I have a v_db variable. Don't worry about v_db and @j is the search string I pass to the select statement. I wish there was a nice GUI for visualizing joins.

select "',v_db,'", ',v_db,'.node.nid, LEFT(',v_db,'.node.title,30), LEFT(',v_db,'.body.body_value,300) from ',v_db,'.node INNER JOIN ',v_db,'.field_data_body AS body ON node.nid = body.entity_id WHERE body.body_value like ',@j);

thanks

1
  • Wouldn't this be easier with Views? You know about Views, correct?
    – Kevin
    Nov 19, 2018 at 14:37

1 Answer 1

0

I needed to do something a bit similar a while ago, and used the drupal field definition tables to identify the field type (text/long et al) and work from there to the nodes. I suggest you do likewise.

You could consider using the mysql fulltext search facilities - it is much faster and much more capable than 'like'.

Of course, the drupal way would be to configure the search module properly...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.