public function save($data = array())
 {
     $editMode = $this->getId() ? true : false;
     $res = parent::save($data);
     if ($res === false) {
         return false;
     }
     global $wpdb;
     if ($editMode) {
         $sql = $wpdb->prepare("UPDATE " . $wpdb->prefix . "sg_image_popup SET url=%s WHERE id=%d", $this->getUrl(), $this->getId());
         $res = $wpdb->query($sql);
     } else {
         $sql = $wpdb->prepare("INSERT INTO " . $wpdb->prefix . "sg_image_popup (id, url) VALUES (%d,%s)", $this->getId(), $this->getUrl());
         $res = $wpdb->query($sql);
     }
     return $res;
 }
Esempio n. 2
0
 public function save($data = array())
 {
     $editMode = $this->getId() ? true : false;
     $res = parent::save($data);
     if ($res === false) {
         return false;
     }
     $sgHtmlPopup = $this->getContent();
     global $wpdb;
     if ($editMode) {
         $sgHtmlPopup = stripslashes($sgHtmlPopup);
         $sql = $wpdb->prepare("UPDATE " . $wpdb->prefix . "sg_html_popup SET content=%s WHERE id=%d", $sgHtmlPopup, $this->getId());
         $res = $wpdb->query($sql);
     } else {
         $sql = $wpdb->prepare("INSERT INTO " . $wpdb->prefix . "sg_html_popup (id, content) VALUES (%d,%s)", $this->getId(), $sgHtmlPopup);
         $res = $wpdb->query($sql);
     }
     return $res;
 }