Save the cloud after the creation

This commit is contained in:
Gregory Trolliet 2020-11-25 22:28:36 +01:00
parent fea36cb867
commit 3fbeb06948

21
db.php
View file

@ -215,6 +215,13 @@ class DataBase
} catch (PDOEXception $e) {
return false;
}
$this->cloud = array(
'id' => $this->db->lastInsertId(),
'code' => $ref,
'size' => $size,
'delete_t' => $duration,
'text' => $text,
);
return true;
}
public function loadCloud($ref)
@ -225,6 +232,11 @@ class DataBase
return $this->loadCloudByCode($ref);
}
}
/**
* Load the cloud by its id
* @param int $id code of the cloud
* @return boolean True if the loading is done, False otherwise
*/
public function loadCloudById(int $id)
{
$stmt = $this->db->prepare("
@ -240,13 +252,18 @@ class DataBase
'code' => $data['code'],
'size' => $data['size'],
'delete_t' => $data['delete_t'],
'text' => $data['test'],
'text' => $data['text'],
);
return true;
}
$this->cloud = null;
return false;
}
/**
* Load the cloud by its code
* @param string $code code of the cloud
* @return boolean True if the loading is done, False otherwise
*/
public function loadCloudByCode(string $code)
{
$stmt = $this->db->prepare("
@ -262,7 +279,7 @@ class DataBase
'code' => $data['code'],
'size' => $data['size'],
'delete_t' => $data['delete_t'],
'text' => $data['test'],
'text' => $data['text'],
);
return true;
}