Fixing PDO fetching
This commit is contained in:
parent
f8f4398007
commit
a4db3c8391
@ -45,18 +45,18 @@ class Posts
|
|||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
$id = implode('', $id);
|
$id = implode('', $id);
|
||||||
}
|
}
|
||||||
$posts = $this->post->showSingle($id);
|
$post = $this->post->showSingle($id);
|
||||||
$categories = $this->post->showCategories();
|
$categories = $this->post->showCategories();
|
||||||
$users = $this->access->showSingle($id);
|
$user = $this->access->showSingle($id);
|
||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$timestamp = $date->format("Y/m/d H:i:s");
|
$timestamp = $date->format("Y/m/d H:i:s");
|
||||||
// echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html
|
// echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html
|
||||||
View::render(
|
View::render(
|
||||||
'Data/edit_pengumuman.html',
|
'Data/edit_pengumuman.html',
|
||||||
[
|
[
|
||||||
'posts' => $posts,
|
'post' => $post,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'users' => $users,
|
'user' => $user,
|
||||||
'timestamp' => $timestamp,
|
'timestamp' => $timestamp,
|
||||||
'token' => Token::generate()
|
'token' => Token::generate()
|
||||||
]
|
]
|
||||||
|
@ -63,7 +63,7 @@ class Post extends \Core\Model
|
|||||||
|
|
||||||
if ($query->execute([$id])) {
|
if ($query->execute([$id])) {
|
||||||
if ($query->rowCount() === 1) {
|
if ($query->rowCount() === 1) {
|
||||||
$result = $query->fetchAll(\PDO::FETCH_ASSOC);
|
$result = $query->fetch(\PDO::FETCH_ASSOC);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
{% block title %}Edit Pengumuman{% endblock %}
|
{% block title %}Edit Pengumuman{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{% for post in posts %}
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<h3>Pengumuman {{ post.id }}</h3>
|
<h3>Pengumuman {{ post.id }}</h3>
|
||||||
|
|
||||||
@ -36,11 +35,9 @@
|
|||||||
|
|
||||||
<label>Dibuat oleh: </label>
|
<label>Dibuat oleh: </label>
|
||||||
<span>
|
<span>
|
||||||
{% for user in users %}
|
|
||||||
{% if post.creator == user.id %}
|
{% if post.creator == user.id %}
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -69,11 +66,9 @@
|
|||||||
{% if post.editor == "0" %}
|
{% if post.editor == "0" %}
|
||||||
-
|
-
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for user in users %}
|
|
||||||
{% if post.editor == user.id %}
|
{% if post.editor == user.id %}
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
<input type="hidden" name="editor" value="3"><!-- User -->
|
<input type="hidden" name="editor" value="3"><!-- User -->
|
||||||
@ -122,5 +117,4 @@
|
|||||||
<button type="submit">Nonaktif</button>
|
<button type="submit">Nonaktif</button>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user