I'm wondering if anybody has a legend that explains how this data is entered into the database?

a:3:{s:5:"roles";a:1:{i:0;s:1:"2";}s:17:"mimemail_textonly";s:1:"0";s:7:"contact";s:1:"0";}

I'm trying to merge another contacts database into the drupal one, and this field called "DATA" in the users table, is pretty cryptic!

Thank you!

Comments

Jo Wouters’s picture

The data-field contains serialized (see php-manual: http://be.php.net/manual/en/function.serialize.php) data.

To get the data in a usefull format for what you want, you should write a php-script that does an unserialize to create the 'original' data-format (your example represents an array).

papermonster’s picture

The data stored in the data field has been Serialized.

To unserialize it use the unserialize() function.

This will then turn the data into an array.

So, Unserialize both data fields, then do an array_merge() on the two resulting arrays. Then serialize() the new array and reenter it into the users table.

That should do it.

papermonster’s picture

Beat me to it :D

rjl’s picture

Not sure if the previous responders have addressed your question

I'm wondering if anybody has a legend that explains how this data is entered into the database?

And I do not mean to belittle their responses at all, but the question as to how that data came to be is very important.

For example, in this particular entry, the user is indicated as having one role (role id 2), their text only mail value is 0, (which I believe to be NO, but am not certain) and a contact value of 0 which indicates the user is not accepting emails.

This data is made available by accessing the drupal user object, the currently logged in user via the global $user variable, any other user by loading a user object. I don't believe this data is/was intended to be accessed by a query.

please read the drupal docs for more information, a great place to start would be hook_user.

As for merging a contacts database... While not sure, in general when someone says contacts database, I think of fields such as name, address, phone, etc. If that is your case, please take a look at the profile module. It is part of the drupal core, though is not enabled by default.

Hope this is useful

luyendao’s picture

I want to thank everyone for their replies - i use drupal on a very superficial level, in the sense of how it manages content, and interacts with users, so when it comes to more complex technical things, i depend on the intelligence of others, and i'm glad to see there's an abundance of intelligent folk in the drupal community.

Thanks again!