Bluz\Db\Row::save PHP Method

save() public method

This performs an intelligent insert/update, and reloads the properties with fresh data from the table on success.
public save ( ) : mixed
return mixed The primary key value(s), as an associative array if the key is compound, or a scalar if the key is single-column
    public function save()
    {
        $this->beforeSave();
        /**
         * If the primary key is empty, this is an INSERT of a new row.
         * Otherwise check primary key updated or not, if it changed - INSERT
         * otherwise UPDATE
         */
        if (!sizeof(array_filter($this->getPrimaryKey()))) {
            $result = $this->doInsert();
        } elseif (sizeof(array_diff_assoc($this->getPrimaryKey(), $this->clean))) {
            $result = $this->doInsert();
        } else {
            $result = $this->doUpdate();
        }
        $this->afterSave();
        return $result;
    }