简体   繁体   中英

Concatenate String Constant with auto incremented integer and store in mysql database

I want to Store something like this in userID of Database(DDN00000001,DDN00000002,DDN00000003 and so on , as user ID)

How to concatenate the string in front of integer and store in database.

If you want to convert integer identifiers to this form in PHP, before sending it to the database, you can use str_pad :

$user_id = 1;
$padded_user_id = 'DDN' . str_pad ($user_id, 8, '0', STR_PAD_LEFT);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM