diff --git a/models/Post.php b/models/Post.php index bc368b9..6adb94a 100755 --- a/models/Post.php +++ b/models/Post.php @@ -44,13 +44,12 @@ class Post { $stmt->execute(); $result = $stmt->fetchAll(); - $stmtTotal = $this->conn->prepare("SELECT COUNT(*) as count; FROM ".$this->postTable); + $stmtTotal = $this->conn->prepare("SELECT COUNT(*) as count FROM ".$this->postTable); $stmtTotal->execute(); $allResult = $stmtTotal->fetch(PDO::FETCH_ASSOC); - $allRecords = $allResult['count']; + $allRecords = $allResult['count'] * 1; - - $displayRecords = count($result); + $posts = array(); foreach ($result as $post) { $rows = array(); @@ -76,7 +75,7 @@ class Post { $output = array( "draw" => intval($_POST["draw"]), - "iTotalRecords" => $displayRecords, + "iTotalRecords" => count($posts), "iTotalDisplayRecords" => $allRecords, "data" => $posts ); @@ -123,12 +122,21 @@ class Post { $stmt->bindParam("s", $this->status); $stmt->bindParam("u", $this->updated); $stmt->bindParam("cr", $this->created); - - if($stmt->execute()){ - return $this->conn->lastInsertId(); - } - } - } + fetch(PDO::FETCH_ASSOC); + return $result['count']; + } +} +?> public function update(){