Class to display different views for my blog.
class SB_Display { public function __contruct() { include_once('settings/db.settings.php'); $mysqli = new mysqli($SB_dbsettings['host'],$SB_dbsettings['user'],$SB_dbsettings['pass'],$SB_dbsettings['dbname']); } private function List_Display() { $VIEW = ''; include_once('views/list.html.view.php'); $sql = "SELECT * FROM sb_posts ORDER BY ID DESC LIMIT '$SETTINGS->maxposts'"; $sql = $mysqli->real_escape_string($sql); $res = $mysqli->mysqli_query($sql); if($res->numrows > 0) { $res->data_seek(0); while ($row = $res->fetch_assoc()) { foreach($row as $key => $value) { $BLOG->$key = $value; $VIEW .= $HTML; } } } else { $VIEW .= 'No Posts To Display'; } return $VIEW; } private function Single_Display($id) { $VIEW = ''; include_once('views/single.html.view.php'); $sql = "SELECT * FROM sb_posts WHERE BID = '$id'"; $sql = $mysqli->real_escape_string($sql); $res = $mysqli->mysqli_query($sql); $row = $res->fetch_assoc(); foreach($row as $key => $value) { $BLOG->$key = $value; } $VIEW .= $HTML; return $VIEW; } private function Create_Display() { include_once('views/create.html.view.php'); return $HTML; } private function Edit_Display($id) { $VIEW = ''; $sql = "SELECT * FROM sb_posts WHERE BID = '$id'"; $sql = $mysqli->real_escape_string($sql); $res = $mysqli->mysqli_query($sql); $row = $res->fetch_assoc(); foreach($row as $key => $value) { $BLOG->$key = $value; } $BLOG->id = $id; $VIEW .= $HTML; return $VIEW; } public function SB_Get_Display($type,$id) { switch($type) { case 'list': $this->content = List_Display(); return $this; break; case 'single': $this->content = Single_Display($id); return $this; break; case 'create': $this->content = Create_Display(); return $this; break; case 'edit': $this->content = Edit_display($id); return $this; break; } } } When using this class in the following manner ..
$BODY = new SB_Display(); $BODY->SB_Get_Display('list',''); I get this error:
Fatal error: Call to undefined function List_Display()
I can't figure out why. Any help would be greatly appreciated.
mysqliis only being saved in a local variable, not on the object.)