I've been using EntityFieldQuery to query my fields but I need the SQL 'like' operator. For this I'm querying the database manually. Question: How do I get the name of a field's table?
What you need to use is the
, which works pretty much like
propertyCondition, only you are adding a condition for the field and not the entity or one of it's properties.
This is how you should query fields and entities.
If you wanted to get info about the how the data of a field was stored, that information is available on the field itself. So you could do
$field = field_info_field('field_name'); $storage_details = $field['storage']['details'];
What info you get depends on how the field is stored, as Drupal support multiple storage backends for fields.
There is another way for obtaining storage details - field_info_fields() function. If you need to get more than one table (data and revisions in your situation) you may use it
$fields = field_info_fields(); $field_current_tbl_name = array_keys($fields[FIELD_NAME]['storage']['details]['sql']['FIELD_LOAD_CURRENT']); $field_revision_tbl_name = array_keys($fields[FIELD_NAME]['storage']['details]['sql']['FIELD_LOAD_REVISION']);
Don't forget that field_info_fields() - memory eater, so it is better to use field_info_field() if you need only single field data.