feat: add custom avatar functionality (#248)
Co-authored-by: Dante Bradshaw <plansuperior@gmail.com>
This commit is contained in:
co-authored by
Dante Bradshaw
parent
40bcf3485e
commit
1dbebd3918
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This migration script updates the avatar field of the user table to use the new avatar path.
|
||||
*/
|
||||
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$sql = "SELECT avatar FROM user";
|
||||
$stmt = $db->prepare($sql);
|
||||
$result = $stmt->execute();
|
||||
$row = $result->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
$avatar = $row['avatar'];
|
||||
|
||||
if (strlen($avatar) < 2) {
|
||||
$avatarFullPath = "images/avatars/" . $avatar . ".svg";
|
||||
$sql = "UPDATE user SET avatar = :avatarFullPath";
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->bindValue(':avatarFullPath', $avatarFullPath, SQLITE3_TEXT);
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user