Set Default User Field MySQL Loop

frm

Well-known member
Trying to set a default user field for all current members as it just reverts to 'no selection' and there must be one selected for something to work.

I tried this (MySQL), but getting errors:
Code:
CREATE PROCEDURE insertproc()
BEGIN
    DECLARE i int DEFAULT 0;
    WHILE i <= 10000 DO
        INSERT INTO xf_user_field_value VALUES(i, 'fieldName', '1');
        SET i = i + 1;
    END WHILE;
END//

Dunno how to create a standalone PHP file for a for loop using config.php but will go down that route next...
 
1) alter the table to have the default
2) run an update on the table where field = null to populate

new rows will get the default, old ones won't.
 
1) alter the table to have the default
2) run an update on the table where field = null to populate

new rows will get the default, old ones won't.
Can't be done because rows need to be inserted for each member without selection. So, need to figure out a MySQL loop to insert those rows or try a PHP script or BASH.
 
It's a required selection so new members will be added but I'll lose out on ones opting in.
 
Back
Top Bottom