rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

commit af1a37b3d4410b5c9bc9e25ec075ec0a72948310
parent f0c054cef211fc5246f0b3e01049968fa2360e02
Author: MTRNord <mtrnord1@gmail.com>
Date:   Thu, 19 Mar 2015 18:20:46 +0100

add function to API

Diffstat:
Mcore/api/v1/DbHandler.class.php | 25+++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/core/api/v1/DbHandler.class.php b/core/api/v1/DbHandler.class.php @@ -240,10 +240,31 @@ class DbHandler { * @param String $task_id id of the task */ public function getPosts($post_id) { + if ($resultat = $connection->query('SELECT id FROM posts')) { + while($daten = $resultat->fetch_object() ){ + $post_id_clean = $daten->id; + } if ($post_id == NULL) { - return $all; + $x = 1; + while ($x < $post_id_clean+1){ + $stmt = $this->conn->prepare("SELECT id,title,text,author,category,date FROM posts WHERE id = ?"); + $stmt->bind_param("i", $id); + if ($stmt->execute()) { + $post["$x"] = $stmt->get_result()->fetch_assoc(); + if ($post["$x"]["text"] != NULL){ + $post["$x"]["text"] = html_entity_decode($post["text"]); + }else{ + $post["$x"] = NULL; + } + $stmt->close(); + return $post; + } else { + return NULL; + } + $x = $x+1; + $id = $id+1; + } }else{ - $stmt = $this->conn->prepare("SELECT id,title,text,author,category,date FROM posts WHERE id = ?"); $stmt->bind_param("i", $post_id); if ($stmt->execute()) {