Drupal CCK delta value and other mysteries

For my aim to create an import-script (see other blog entry), I had to go deeper into Drupal DB values.

I don't like to do things again and again and I hope, that this note will be useful for somebody else perhaps, too.

My understanding of the common drupal cck-columns is:

"delta": Value for sorting the fields
==> 0 = first value
==> 1 = second value
... and so on.

Another aspect that is hard to understand, is the ..._data - column.
It seems to break the rules for database normalization and sets several values as a list in one column.

For example:
a:2:{s:3:"alt";s:0:"";s:5:"title";s:0:"";}
(CCK Image field)

As I understand this, it seems to encapsulate information about which data to use for the (html-)attributes.

An empty entry would look like this:
'a:0:{}'

From my point of view this code really smells bad. It is hard to understand, not db-normalized, ...

Technically it is just a serialized array, for example:

PHP:
print_r(serialize(array('a'=>'value a',
'b'=>'value b')));

RESULT:
a:2:{s:1:"a";s:5:"value a";s:1:"b";s:4:"value b";}

Anyway, we have to struggle with it and my oppinion doesn't matter in this case. For my script I will just leave this empty ('a:0:{}') and see, if it will cause problems. At the moment I think, there's no other possibility, because I can't find a documentation about this. So if you know better, please let me know!

Einordnung:

Comments

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Internal paths in single or double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or path. Paths to files in single or double quotes, written as "files:somefile.ext", for example, are replaced with the appropriate URL that can be used to download the file.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><blockquote>
  • Lines and paragraphs break automatically.
  • Pairs of<blockquote> tags will be styled as a block that indicates a quotation.
  • You can enable syntax highlighting of source code with the following tags: <c>, <cpp>, <css>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <smarty>, <xml>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Textual smileys will be replaced with graphical ones.
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.