Esempio n. 1
0
 /**
  * Almacena las categorías a las que pertenece el artículo
  */
 public function save_categories()
 {
     if (empty($this->categos)) {
         $this->add_categories(MWFunctions::default_category_id());
     }
     $this->db->queryF("DELETE FROM " . $this->db->prefix("mw_catpost") . " WHERE post='" . $this->id() . "'");
     $sql = "INSERT INTO " . $this->db->prefix("mw_catpost") . " (`post`,`cat`) VALUES ";
     foreach ($this->categos as $k) {
         $sql .= "('" . $this->id() . "','{$k}'), ";
     }
     $sql = substr($sql, 0, strlen($sql) - 2);
     if ($this->db->queryF($sql)) {
         return true;
     } else {
         $this->addError($this->db->error());
         return false;
     }
 }