[SOLVED] CBSubs to change username first time user subscrib

11 years 3 days ago #147037 by Ducatiklubben
Replied by Ducatiklubben on topic Re:CBSubs to change username first time user subscrib
Problem solved!

Since we needed to verify if username was a number or not, we had to use a Stored Procedure in the database to make this work.
Here's the code that we used:
[code:1]CREATE PROCEDURE updateUser(IN user_id CHAR(64))
declare user_name varchar(64);

SET user_name = (select username from ducati_users where id = user_id);

if user_name REGEXP '^-?[0-9]+$' = 0 then

UPDATE ducati_users as a
SELECT * FROM ducati_users
WHERE username>1 ORDER BY username DESC LIMIT 1
) AS b on a.id = user_id AND b.username>1
SET a.username = b.username + 1;

In the SQL Action tab in CBSubs we use the "call" command to make the Stored procedure to be used:
[code:1]call updateUser([user_id]);

Thanks for all your help

Post edited by: Ducatiklubben, at: 2010/11/25 18:02

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.119 seconds

Facebook Twitter LinkedIn