SQL Query for Custom Profil Field

Pinn

Well-known member
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?
 
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);
 
Checkboxes are multi-select. Those values are stored as arrays. You will end up with a query like this:

Rich (BB 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.
 
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);
 
Back
Top Bottom