page de recher plus modifs vers un system de controllers

This commit is contained in:
2019-03-01 22:56:39 +01:00
parent b339e09082
commit 91806d4112
11 changed files with 294 additions and 54 deletions

View File

@ -99,9 +99,12 @@ class Post {
return $this->dt;
}
/**
*
* @return \App\DB\Tag[]
*/
public function getTags() {
$temp = array();
if ($this->tags == null) return $temp;
foreach ($this->tags as $tag) {
$temp[] = Tag::get($tag);
@ -160,7 +163,17 @@ class Post {
$res = array();
foreach ($posts as $post) {
$res[] = Post::fromArray($post);
$post = Post::fromArray($post);
$query = "SELECT * FROM post_tag WHERE post_id=". $post->getId();
$tagList = array();
$bool = $pdo->query($query);
// var_dump($bool->fetchAll());
if($bool) foreach ($pdo->query($query)->fetchAll() as $tag) {
$tagList[] = $tag["tag"];
}
$post->setTags($tagList);
$res[] = $post;
}
return $res;