durpleman
durpleman

Reputation: 13

Where in the database are content type fields stored in Drupal 6

I need to access particular fields of a content type so that I can sort and display what I want accordingly. I do not have the Views module available because I do not have installation permissions, so I have to do this with a query and some php magic.

I received some very helpful information about the table names of fields for Drupal 7, but it appears that the organization/conventions for field values and where they are stored has changed since 6.

I found out in Drupal 7 that each content type field is stored in its own separate table. Assuming I had a field which I called group, the table name would be "field_data_field_group."

However, when I attempt to use this convention on my Drupal 6 site, it says this table does not exist.

My question is what is the name of the table fields are stored in? Or is it a completely different system than Drupal 7? Thanks for taking a look.

Upvotes: 1

Views: 5014

Answers (1)

Boriana Ditcheva
Boriana Ditcheva

Reputation: 2015

For Drupal 6, look in the following couple of places:

  1. In the Drupal 6 database, look for a table that's called content_[your_field_name], for example, content_field_brief_description. Do a SELECT * to see what rows you have for that field table, if it exists.

  2. Look for a table called content_type_[your_content_type], for example content_type_resource. Do the same with that table and see if you get any columns in that one for fields, other than the title/body that may be associated with that content type.

Let us know if that worked!


Edit:

Sample code:

$result = db_query("SELECT * FROM {table_name}");
while ($row = db_fetch_array($result)) {
   // do something like drupal_set_message(var_dump($row));
}

Keep the curly brackets as are, but just replace that with the table name you're using at the moment...

Upvotes: 2

Related Questions