public function save(WpProQuiz_Model_Category $category) { $type = $category->getType(); if ($category->getCategoryId() == 0) { $this->_wpdb->insert($this->_tableCategory, array('category_name' => $category->getCategoryName(), 'type' => empty($type) ? 'QUESTION' : $type), array('%s', '%s')); $category->setCategoryId($this->_wpdb->insert_id); } else { $this->_wpdb->update($this->_tableCategory, array('category_name' => $category->getCategoryName()), array('category_id' => $category->getCategoryId()), array('%s'), array('%d')); } return $category; }