mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 11:43:16 +02:00
✨ Added api route getAuthorsCountByAuthor(author_name)
This commit is contained in:
@@ -40,7 +40,7 @@ class dump {
|
||||
return $theses_array;
|
||||
}
|
||||
|
||||
public static function getAuthorsByAuthors(mixed $author_name) : array {
|
||||
public static function getAuthorsByAuthor(string $author_name) : array {
|
||||
$array = [];
|
||||
|
||||
$author_name = '%' . $author_name . '%';
|
||||
@@ -61,6 +61,23 @@ class dump {
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function getAuthorsCountByAuthor(string $author_name) : int {
|
||||
$author_name = '%' . $author_name . '%';
|
||||
|
||||
$pdo_obj = new conf();
|
||||
$pdo = $pdo_obj->getPDO();
|
||||
|
||||
$stmt = $pdo->prepare("SELECT COUNT(author) FROM theses WHERE author LIKE :author_name;");
|
||||
$stmt->bindParam(':author_name', $author_name, PDO::PARAM_STR, 100);
|
||||
$stmt->execute();
|
||||
|
||||
while ($obj = $stmt->fetchObject()) {
|
||||
foreach ($obj as $elem) {
|
||||
return $elem;
|
||||
}
|
||||
} return 0;
|
||||
}
|
||||
|
||||
public function sendThese($pdo) {
|
||||
$data = [
|
||||
'author' => $this->these->getAuthor(),
|
||||
|
||||
Reference in New Issue
Block a user