query("SELECT COUNT(*) FROM blog_posts WHERE post_content<>'' AND post_deleted=0")->fetchColumn(); } public function GetLatest($count=1,$offset=0){ $prep=self::$PDO->prepare("SELECT post_id FROM blog_posts WHERE post_content<>'' AND post_deleted=0 ORDER BY post_timestamp DESC LIMIT ?,?"); $prep->bindValue(1,(int)$offset,PDO::PARAM_INT); // can't just use array in execute this time as execute array is treated like strings $prep->bindValue(2,(int)$count,PDO::PARAM_INT); $prep->execute(); $ids=$prep->fetchAll(PDO::FETCH_COLUMN); $posts=array(); foreach ($ids as $id) $posts[]=new BlogPost($id); return $posts; } public function GetAll(){ $posts=array(); self::SetupPDO(); $ids=self::$PDO->query("SELECT post_id FROM blog_posts WHERE post_deleted=0")->fetchAll(PDO::FETCH_COLUMN); foreach ($ids as $id) $posts[]=new BlogPost($id); return $posts; } }