/** * @param bool|false $ignore * @return bool|int */ public function save($ignore = false) { $this->beforeSave(); $query = new QueryBuilder($this); $result = $this->exists() ? $query->update() : ($this->id = $ignore ? $query->ignore()->insert() : $query->insert()); $this->afterSave(); return $result; }