php - how to set default value as text and auto increment in mysql table -
i trying set default username wechat have wxid_1234 can set default username in our mysql table?
there table named 'username' , have 2 columns: 'username' , 'phone'. since 'username' needs set foo_123 , may auto increased foo_124, foo_125 etc. changed afterwards.
so possible set username that? if not other method it.
yes, can that, 2 queries, , have have autoincrementing user_id
column:
$sql = $dbo->prepare('insert users(username, phone) values("temp", ?)'); $sql->execute(array($phone_number)); $id = $dbo->lastinsertid(); $sql = $dbo->prepare("update users set username=? id=?"); $username = "foo_" . $id; $sql->execute(array($username, $id));
Comments
Post a Comment