Hi, just discovered this in my db..

I have custom content type "flat" (on real estate page), some of the cck field values are stored in "content_type_flat", which is what I expected, but some of them, fg. "field_rent_sell" are stored in "content_field_rent_sell" etc.., is there a reason for this? All of them are text type check boxes/radio buttons with allowed values like this..

return array(
'1' => t('Sell'),
'2' => t('Rent'),
);

Comments

czeky’s picture

Version: 6.x-2.x-dev » 6.x-2.4
markus_petrux’s picture

Status: Active » Fixed

At this moment, CCK2 uses 2 different storage methods for fields: a) table per content type (default), b) table per field. This is not user selectable. CCK2 switches to b) when the field is shared between several content types (you used add existing field), or when the field allows multiple values, where in addition to store the field on its own table, a delta column is added to the primary key. If any of the conditions that triggered b) changes, then CCK re-evaluates, and switches back to a) storage as appropriate.

If you don't use multiple values for a field, and you want to make sure this field is stored in the content type related table, then do not shared this field between more than one content type.

tinem’s picture

VERY interesting and important message which will be a concern to my testsite http://www.tinemuller.dk/drupal/node/1097 making a map without using any map/locations modules but storing the data in Drupal and then getting the info from the table in my situation from my Content type Copenhagen which is content_type_copenhagen.

I'm also going to use CCK fields for several multiple values for people to choose so have to figure out how to get this done to show on the big map if I want to from the other table then but it would have been nice if ALL the info was in ONE table though. :-)

markus_petrux’s picture

Well, you may or may not want to share a field between content types. The fact a separate table will be used when a field is shared is something to take into account before you share a field. In any case, CCK gives you the choice to do it or not.

When the field allows multiple values, then it must be stored into a separate table because a new delta column needs to be added to the primary key. This is an attribute that is only related to the field that is defined to allow multiple values. So its data needs a separate table.

czeky’s picture

Thanx, the reason I'm asking is.. I need to write custom module to search custom values in db

$sql = db_query("SELECT $amount, $currency, nid, field_city_value FROM {content_type_flat} WHERE $amount >= $price_start AND $amount <= $price_end ORDER BY $amount DESC");

this is working fine, because in one table, but I need more values, now.. from other table (as described above), I have radio button Rent or Sell (with values "rent" and "sell") in the other table, and I need to display and sort these values as well. I just don't have a clue how to do it together.. ;-(

is it possible to do something like SELECT columnX FROM tableX WHERE xxx AND SELECT columnY FROM tableY WHERE yyy ORDER BY zzz DESC?

many thanx guys

markus_petrux’s picture

You can use CCK APIs for this. Examples:

// Obtain information about a field attached to a node type.
$field = content_fields('field_name', 'node_type');

// Obtain database information about the field.
$db_info = content_database_info($field);

// $db_info['table'] contains the name of the table where the field is stored.

// $db_info['columns'] contains information about the database columns of the field.
tinem’s picture

I have made my first filed with checkbox/radiobuttons for 2 different chooses and I can see that both answer is in the same table as the other fields which was want I wanted. How can that be?

I have:
Betaling2:
N/A
2gratis
2betalingstoilet

Don't know what N/A is about?

This is one toilet http://www.tinemuller.dk/drupal/node/1090 and the other http://www.tinemuller.dk/drupal/node/1100.

This is what I have at the bottom of the site in PHP:
return array(
'0' => t('2gratis'),
'1' => t('2betalingstoilet'),
);

In my table field_betaling2_value I have "1" and "2" for different toilets and think this is how it should be, right?

tinem’s picture

Just discovered that I hadn't been giving the CCK permission for these filelds so Anomymous users could not see the info from this fields but it's ok now - http://www.tinemuller.dk/drupal/copenhagen.

Maybe some one can answer to my question now, please?

markus_petrux’s picture

Re: Don't know what N/A is about?

This is added by CCK optionwidgets because the field is defined as optional. You can change the text of this option overiding the function theme_optionwidgets_none() in your theme.

Search the issues queue as this N/A thing has been discussed several times.

Re: In my table field_betaling2_value I have "1" and "2" for different toilets and think this is how it should be, right?

I think this has been answered in #2 and #4? Since this one seems to be a field that only accepts one value, if you want it to be stored in the content type table, then don't share this field with other content types. If you do, CCK will swicth to *per field storage* and create a table for this field.

tinem’s picture

@markus_petrux wrote:
Search the issues queue as this N/A thing has been discussed several times.

I can't figure out what to choose to get info about this in issue. Can someone help, please?

markus_petrux’s picture

Follow this link and you'll find one or two issues:

http://drupal.org/project/issues/cck?text=theme_optionwidgets_none&statu...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.