entity.php
public function save()
    {

        if ($this->beforeSave() === false) {
            return;
        };
        $conn = DB::getConnect();
        $meta = $this->getMetadata();
        $flist=$this->fields ;
        unset($flist[$meta['keyfield']] );//убираем  ключевое  поле с  запроса        
        if ($this->fields[$meta['keyfield']] > 0) {

            $conn->AutoExecute($meta['table'], $flist, "UPDATE", "{$meta['keyfield']} = " . $this->fields[$meta['keyfield']]);
            $this->afterSave(true);
        } else {
            $conn->AutoExecute($meta['table'], $flist, "INSERT");
            $this->fields[$meta['keyfield']] = $conn->Insert_ID();
            $this->afterSave(false);
        }
    }
public function save()
    {

        if ($this->beforeSave() === false) {
            return;
        };
        $conn = DB::getConnect();
        $meta = $this->getMetadata();
        $flist=$this->fields ;
        unset($flist[$meta['keyfield']] );//убираем  ключевое  поле с  запроса        
        if ($this->fields[$meta['keyfield']] > 0) {

            $conn->AutoExecute($meta['table'], $flist, "UPDATE", "{$meta['keyfield']} = " . $this->fields[$meta['keyfield']]);
            $this->afterSave(true);
        } else {
            $conn->AutoExecute($meta['table'], $flist, "INSERT");
            $this->fields[$meta['keyfield']] = $conn->Insert_ID();
            $this->afterSave(false);
        }
    }
Сохраняет  сущность  в  БД
Если  сущность новая создает запись