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

SQL Query for Custom Profil Field

Pinn

Active member
#1
I Need a SQL Query for my Profil Field

ID: fakecheck
Option: benutzer_ungeprueft

All User to the Option: benutzer_ungeprueft

Does anyone know of the SQL query for this?
 

Pinn

Active member
#6
Thanks, so ok:??

Code:
INSERT INTO xf_user_field_value (user_id, field_id, field_value)
SELECT user_id, 'fakecheck', 'benutzer_ungeprueft'
FROM xf_user
ON DUPLICATE KEY UPDATE
field_value = VALUES(field_value);
 

Jake Bunce

XenForo moderator
Staff member
#12
Checkboxes are multi-select. Those values are stored as arrays. You will end up with a query like this:

Code:
INSERT INTO xf_user_field_value (user_id, field_id, field_value)
	SELECT user_id, 'field_id', 'a:1:{s:5:"value";s:5:"value";}'
	FROM xf_user
ON DUPLICATE KEY UPDATE
	field_value = VALUES(field_value);
This is serialized data. Be careful that the string lengths match the value.
 

Pinn

Active member
#13
Yes it works:

Code:
INSERT INTO xf_user_field_value (user_id, field_id, field_value)
    SELECT user_id, 'fakecheck', 'a:1:{s:13:"benutzer_echt";s:19:"benutzer_ungeprueft";}'
    FROM xf_user
ON DUPLICATE KEY UPDATE
    field_value = VALUES(field_value);