public function save(Model_Category $category) { if ($category->id) { $where[] = 'id = ' . $category->id; $this->_db->update('categories', $category->toArray(), $where); } else { $this->_db->insert('categories', $category->toArray()); $category->id = $this->_db->lastInsertId(); } return $category; }