1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 SQL Query to set a profile field value

Discussion in 'XenForo Questions and Support' started by Rob, Apr 10, 2014.

  1. Rob

    Rob Well-Known Member

    I'd like to run an SQL query that will set a profile field value for any user who does not already have the field set. Is this possible?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Code:
    UPDATE xf_table SET option = 'value' WHERE option = '';
    That's the general syntax.
    It depends on the table and field type though.
    Some fields can't be updated like that, if they contain serialised arrays for example.

    Take a backup first before doing any work on the database.
     
  3. Rob

    Rob Well-Known Member

    The problem is, only 10K entries exist in the table and there are 55K users.

    I'd have to use a query that will add a row for the user if one didnt already exist.... its sounding more like a PHP script actually come to think of it as I dont think a query will do the whole thing.
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Which table/column is it?
     
  5. Rob

    Rob Well-Known Member

    its for custom user fields - its not serialized. you know the built in user fields. the table i think is xf_user_field_value
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, that's not one which can be updated with a simple SQL query.
    It would require a script.
     
    Rob likes this.
  7. Rob

    Rob Well-Known Member

    Yea, I thought that may be the case.

    Cheers
     

Share This Page