Closed (fixed)
Project:
Examples for Developers
Version:
7.x-1.x-dev
Component:
Field Example
Priority:
Normal
Category:
Support request
Reporter:
Anonymous (not verified)
Created:
4 Mar 2013 at 13:13 UTC
Updated:
8 Jun 2023 at 09:24 UTC
how can i define the database {table},which for the field storage?
In the "field example", the data storage in the {rgb table}, but which function determine the goal {table} of "field_example_rgb"?
i see the code hook_field_schema only determine the structure of database's table,nothing shows its bind to "field_example_rgb",only the key word "rgb".
Comments
Comment #1
rfayThe field API handles its own table creation (which may be different based on the storage back-end selected). You don't get involved in the choice of the name (and shouldn't query it directly or generally even know what it is). Remember that it might have a completely different backend somewhere. Use the field api instead.
Comment #2
mile23Like rfay says, you only give Drupal the schema in hook_field_schema(). That's your declaration that this is the schema for your field.
To do queries against it, you use EntityFieldQuery. We have an issue to create an example of that, with some useful code: #916776: Add an EntityFieldQuery example
Also documentation: http://api.drupal.org/api/drupal/includes%21entity.inc/class/EntityField...