Create new record in SQL table with $data & $this->id
@param $id
@param $data
@return mixed
558906
private function insert($id, $data)
    {
        $platform = $this->persistence->getPlatform();
        $columns = array_merge(array(
            self::DIAGNOSTIC_ID => $id,
            self::DIAGNOSTIC_CREATED_AT => $platform->getNowExpression()
        ), $data);

        $query = 'INSERT INTO ' . self::DIAGNOSTIC_TABLE . '(' . implode(', ', array_map('Doctrine\Common\Inflector\Inflector::tableize',array_keys($columns))) . ')' .
                 ' VALUES (' . str_repeat("?,", count($columns) - 1) . '? )';

        return $this->persistence->exec($query, array_values($columns));
    }
53929
public function set(array $data, $id = null) {
        $id = null === $id ? $this->idGen++ : $id;
        $this->data[$id] = $data;
        self::$dirty[$this->class] = true;
        return $id;
    }
408367
public function addReferences($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Skill not found.']);
		}

		// pass add to internal logic
		try {
			$this->doAddReferences($model, $data);
		} catch (ErrorsException $e) {
			return new NotValid(['errors' => $e->getErrors()]);
		}

		// save and dispatch events
		$this->dispatch(SkillEvent::PRE_REFERENCES_ADD, $model, $data);
		$this->dispatch(SkillEvent::PRE_SAVE, $model, $data);
		$rows = $model->save();
		$this->dispatch(SkillEvent::POST_REFERENCES_ADD, $model, $data);
		$this->dispatch(SkillEvent::POST_SAVE, $model, $data);

		if ($rows > 0) {
			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
971737
public static function create($data = [], Entity $entity = null)
    {
        $record = new static($data, $entity);

        $record->save();

        return $record;
    }
146838
public function update($data, $id) {

		$bean = \R::findOne( $this->type, ' id = :id ', [ ':id' => $id ] );
		if ( !$bean ) {
			throw new \Exception('This '.$this->type.' does not exist.');
		}
		return $this->set($data, $bean);

	}
522022
public function update($id, $data)
    {
        $message = $this->client->put(
            sprintf('buckets/%d/messages/%d.json', $this->bucket, $id),
            [
                'json' => $data,
            ]
        );

        return new Message($this->response($message));
    }
447314
public function findId($id, $data = [])
    {
        if ($id) {
            $this->findOneById($id);
        } else {
            // Reset status when record not found
            $this->isNew = true;
        }

        return $this->fromArray($data);
    }
223540
public function updateKstrukturs($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Skill not found.']);
		}

		// pass update to internal logic
		try {
			$this->doUpdateKstrukturs($model, $data);
		} catch (ErrorsException $e) {
			return new NotValid(['errors' => $e->getErrors()]);
		}

		// save and dispatch events
		$this->dispatch(SkillEvent::PRE_KSTRUKTURS_UPDATE, $model, $data);
		$this->dispatch(SkillEvent::PRE_SAVE, $model, $data);
		$rows = $model->save();
		$this->dispatch(SkillEvent::POST_KSTRUKTURS_UPDATE, $model, $data);
		$this->dispatch(SkillEvent::POST_SAVE, $model, $data);

		if ($rows > 0) {
			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
1139421
public function saveById($id, $data)
    {
        $exists = !is_null($id);
        if (!$exists) {
            $id = $this->findAvailableIdByData($data);
        }
        parent::saveById($id, $data);
        return $id;
    }
926457
public function add(string $id, array $data = []): bool
    {
        try {
            $this->setFile($id);
            if ($this->file) {

                if (!file_exists($this->file)) {
                    //Novo
                    if($this->versionamento) {
                        $data['created'] = strtotime("now");
                        $data['updated'] = strtotime("now");
                        parent::deleteVerion($this->file);
                    }

                    $f = fopen($this->file, "w+");
                    fwrite($f, json_encode($data));
                    fclose($f);

                    return true;
                }
            }
            return false;
        } catch (\Exception $e) {
            return false;
        }
    }
317373
public function save($id, array $data)
    {
        if(!empty($id) && (is_string($id) || is_numeric($id))) {
            $this->setFile($id);
            if ($this->file) {
                if (file_exists($this->file)) {
                    $this->update($id, $data);
                } else {
                    $this->add($id, $data);
                }
            }
        }
    }
810133
public function write(string $id, array $data) : bool
    {
        static $create, $update, $delete;
        $values = $data + compact('id'); // Default.
        unset($values['dateactive']);
        if (!isset($create, $update)) {
            $fields = [];
            $placeholders = [];
            $updates = [];
            foreach ($values as $key => &$value) {
                if ($key == 'data') {
                    $value = base64_encode($value);
                }
                $fields[] = $key;
                $placeholders[] = ":$key";
                if ($key != 'id') {
                    $updates[] = "$key = :$key";
                }
            }
            $create = $this->pdo->prepare(sprintf(
                "INSERT INTO cesession_session (%s) VALUES (%s)",
                implode(', ', $fields),
                implode(', ', $placeholders)
            ));
            $update = $this->pdo->prepare(sprintf(
                "UPDATE cesession_session SET %s WHERE id = :id",
                implode(', ', $updates)
            ));
            $delete = $this->pdo->prepare("DELETE FROM cesession_session WHERE id = :id");
        }
        if ($this->exists) {
            $update->execute($values);
            return (bool)$update->rowCount();
        } else {
            $delete->execute(compact('id'));
            try {
                $create->execute($values);
                return ($affectedRows = $create->rowCount()) && $affectedRows;
            } catch (PDOException $e) {
                $update->execute($values);
                return (bool)$update->rowCount();
            }
        }
    }
836725
public function updateSkills($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Reference not found.']);
		}

		// pass update to internal logic
		try {
			$this->doUpdateSkills($model, $data);
		} catch (ErrorsException $e) {
			return new NotValid(['errors' => $e->getErrors()]);
		}

		// save and dispatch events
		$this->dispatch(ReferenceEvent::PRE_SKILLS_UPDATE, $model, $data);
		$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
		$rows = $model->save();
		$this->dispatch(ReferenceEvent::POST_SKILLS_UPDATE, $model, $data);
		$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);

		if ($rows > 0) {
			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
15279
public function find($id, Data $data = null)
    {
        $id = $this->normalizeID($id);
        $registry = Registry::getInstance();

        if (!$data) {
            if ($data = $registry->get($this->class, $id)) {
                return $data;
            }
        }

        if (!$record = $this->doFind($id)) {
            return false;
        }

        $data = $this->pack($record, $data ?: null);
        $registry->set($data);

        return $data;
    }
471009
public function tokenCreate($id, $token = null, $data = null){
		return $this->object->tokenCreate($id, $token, $data);
	}
313915
public function update($id, $data) {
		$dt = $this->getDataTable();
		
		if (! $dt)
			return $this->createResponse($this->getNameManager()->getTableNames(), 401, "Tabels");
		
		return $this->createResponse([], 200, "{$this->getNameManager()->entityName}: No Update");
	}
742917
public function update($id, $data)
    {
        $document = $this->client->put(
            sprintf('buckets/%d/documents/%d.json', $this->bucket, $id),
            [
                'json' => $data,
            ]
        );

        return new Document($this->response($document));
    }