General save.

@param array  $values
@param string $table
@return int
@throws UniqueConstraintViolationException
@throws \Dibi\Exception
512833
private function generalSave(array $values, string $table): int
    {
        $id = $values['id'];
        unset($values['id']);

        try {
            if (!$id) {
                // add
                return $this->connection->insert($table, $values)->execute();
            } else {
                // update
                if ($values) {
                    return $this->connection->update($table, $values)->where(['id' => $id])->execute();
                } else {
                    // delete
                    return $this->connection->delete($table)->where(['id' => $id])->execute();
                }
            }
        } catch (\Dibi\UniqueConstraintViolationException $e) {
            throw new UniqueConstraintViolationException('Item already exist!');
        }
    }
57260
public function insertMany($table, array $columns, array $values)
    {
        $collection = array();

        foreach ($values as $index => $data) {
            foreach ($data as $key) {
                $collection[$index][] = $this->createUniqPlaceholder($key);
            }
        }

        $this->queryBuilder->insertMany($table, $columns, $collection);
        return $this;
    }
67255
public function setDefinedValues(array $values)
    {
        foreach ($this->_definition as $key => $value) {
            $this->setOptionalValueInArray($key, $values);

            if (!array_key_exists($key, $values)) {
                throw new Exception ('Value is missing for "' . $key . '"');
            }

            $this->$key = $values[$key];
        }

        return $this;
    }
369902
protected function _insert_batch($table, $keys, $values)
	{
		// Multiple-value inserts are only supported as of SQL Server 2008
		if (version_compare($this->version(), '10', '>='))
		{
			return parent::_insert_batch($table, $keys, $values);
		}

		return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
	}
1029937
public function insert(array $values)
    {
        $this->compileWheres();
        $result = $this->query->insert($values);

        return 0 == (int) $result['errors'];
    }
659667
public function insertMany($table, array $columns, array $values)
    {
        $columns = $this->quote($columns);

        // Validate the length
        foreach ($values as $data) {
            $dataCount = count($data);
            $columnsCount = count($columns);

            if ($dataCount !== $columnsCount) {
                throw new LogicException(sprintf('Count mismatch. One collection contains %s keys instead of expected %s', $dataCount, $columnsCount));
            }
        }

        // Generate initial fragment
        $sql = sprintf('INSERT INTO %s (%s) VALUES ', $table, implode(', ', $columns));

        // Generate the rest
        foreach ($values as $data) {
            if (is_array($data)) {
                $sql .= sprintf("(%s), ", implode(', ', $data));
            } else {
                throw new RuntimeException(sprintf('3-rd argument should contain a collection of arrays, one of them is %s', gettype($data)));
            }
        }

        // Tweak the ending fragment
        $sql = substr($sql, 0, -2);
        $sql .= ';';

        // Done there
        $this->append($sql);
        return $this;
    }
350200
private function SaveToTable($table)
    {
        $sql = Access::SqlBuilder();
        $fields = array();
        $setList = null;
        foreach ($this->Elements()->GetElements() as $element)
        {
            $this->HandleElement($table, $element, $fields, $setList);
        }
        if ($setList)
        {
            Access::Connection()->ExecuteQuery($sql->Insert($sql->Table($table, $fields), $setList));
        }
    }
1326450
private function saveValues(array $values, $prefix, SessionInterface $session)
    {
        foreach ($values as $name => $value) {
            $session->set($prefix . $name, $value);
        }
    }
763102
public function add(...$values)
    {
        foreach ($values as $value) {
            $this->table->put($value, null);
        }
    }
1013088
public function setValues(array $values)
    {
        foreach ($values as $key => $value) {
            if (is_integer($value)) {
                // cast integer values silenty to a double value.
                $values[$key] = $value = (double) $value;
            }
            $this->checkType('double', $value, true);
        }
        parent::setValues($values);
    }
1336392
protected function _update($table, $values)
	{
		$this->qb_limit = FALSE;
		$this->qb_orderby = array();
		return parent::_update($table, $values);
	}
717257
public static function insert( $table, $values = array(), $handler = null ) 
	{
		return Query::insert( $table, $values, $handler );
	}
323102
public function setValuesSafe(array $values = [])
    {
        $blacklist = is_array(static::$blacklist) ? static::$blacklist : [static::$primary_key];

        foreach ($values as $key => $value) {
            if (!in_array($key, $blacklist) && isset(self::$column_cache[get_called_class()][$key])) {
                $this->set($key, $values[$key]);
            }
        }
    }
1241397
public function insert(array $values): bool {
    $this->coerceDataTypesToDatabase($values);
    return $this->builder->insert($values);
  }
1253117
public function prepareUpdate($table, array $values) {

        // Initialize the SET.
        $set = [];
        foreach ($values as $k => $v) {
            $set[] = "`" . $k . "` = " . $v;
        }

        // Initialize the query.
        $query = [];

        $query[] = "UPDATE ";
        $query[] = $table;
        $query[] = " SET ";
        $query[] = implode(", ", $set);

        // Return the query.
        return implode("", $query);
    }
353664
public function insert(array $values)
    {
        $result = parent::insert($values);

        $this->handler->setBuilder($this)
            ->invalidateQuery(Reflector::QUERY_TYPE_INSERT, $values);

        return $result;
    }
1234229
public static function insert( $table, $values = array(), $handler = null )
	{
		return Query_Insert::create( $table, $handler )->values( $values );
	}