public function __construct() { $select_sql = "SELECT * from pbglobal"; if ($result = $GLOBALS['mysqli']->query($select_sql)) { $row = $result->fetch_assoc(); $this->TemplateFolder = $row['templatefolder']; $this->PostTemplateName = $row['posttemplatename']; $this->PostFolder = $row['postfolder']; $this->PostUrl = $row['posturl']; $this->CategoryTemplateName = $row['categorytemplatename']; $this->IndexTemplateName = $row['indextemplatename']; $this->IndexFolder = $row['indexfolder']; $this->IndexFileName = $row['indexfilename']; $this->LightCarousel = $row['lightcarousel']; $this->DarkCarousel = $row['darkcarousel']; } else { glogg('something happened:' . $GLOBALS['mysqli']->error); glogg($insert_sql); } }
public static function assignpostcategories($blog) { if ($blog->Categories) { $delete_sql = "DELETE FROM pbpostcategory WHERE postid = {$blog->ID};"; if ($GLOBALS['mysqli']->query($delete_sql)) { foreach ($blog->Categories as $category) { $insert_sql = "INSERT INTO pbpostcategory (postid,categoryid) values ({$blog->ID},{$category->ID});"; if ($GLOBALS['mysqli']->query($insert_sql) == FALSE) { glogg('something happened:' . $GLOBALS['mysqli']->error); glogg($insert_sql); } } } else { glogg('something happened:' . $GLOBALS['mysqli']->error); glogg($insert_sql); } } }
public function Save() { if ($this->ID < 1) { //add new $insert_sql = function () { $col_list = ''; $val_list = ''; if (!empty($this->PostID)) { $col_list .= 'postid,'; $val_list .= "'{$this->PostID}',"; } if (!empty($this->Response)) { $col_list .= 'response,'; $val_list .= "'{$this->Response}',"; } if (!empty($this->Name)) { $col_list .= 'name,'; $val_list .= "'{$this->Name}',"; } if (!empty($this->Email)) { $col_list .= 'email,'; $val_list .= "'{$this->Email}',"; } $col_list .= 'responsedate'; $val_list .= 'now()'; $retval = 'insert into pbuserresponse (' . $col_list . ') values (' . $val_list . ');'; return $retval; }; if ($GLOBALS['mysqli']->query($insert_sql())) { $this->ID = $GLOBALS['mysqli']->insert_id; } else { glogg('something happened:' . $GLOBALS['mysqli']->error); glogg($insert_sql); } } else { //update isok if ($this->IsOK == TRUE) { $update_sql = "update pbuserresponse set isok = '' where id = {$this->ID};"; if ($GLOBALS['mysqli']->query($update_sql())) { } else { glogg('something happened--:' . $GLOBALS['mysqli']->error); glogg($update_sql()); } } } }