Insert a new entity in the storage
@param AbstractEntity $entity
@return mixed
767426
public function insert($entity)
    {
        if (!$entity instanceof $this->entityClass) {
            throw new \InvalidArgumentException(
                "The entity to be inserted must be an instance of {$this->entityClass}."
            );
        }

        return $this->adapter->insert($this->entityTable, $entity->toArray());
    }
375939
protected function prepareDocumentForGet(AbstractDocument $entity): bool
    {
        $document = $entity->getMongoDocument();

        if (!$document or empty($document)) {
            return true;
        }

        foreach ($document as $key => $value) {
            if ($value instanceof BSONDocument) {
                $value = $value->getArrayCopy();
            }
            if (is_array($value) and array_key_exists('document_serialization', $value)){
                $documentEntity = $this->loadDocumentSerializedEntity($value);

                $entity->__set($key, $documentEntity);
            }
        }

        return true;
    }
376935
public static function save($entity): ResultInterface
    {
        $className = \get_class($entity);
        list($table, , , $fields) = self::getFields($entity, 1);
        $instance = self::getInstance($className);

        $fields = $fields ?? [];
        $query  = Query::table($table)->selectInstance($instance);
        // Set Primary Id to Entity
        $query->addDecorator(function ($primaryId) use ($entity, $className) {
            list(, , $idColumn) = self::getTable($className);
            // When Primary Id is auto increment
            $getter = 'get' . StringHelper::camel($idColumn, false);
            $setter = 'set' . StringHelper::camel($idColumn, false);
            if (method_exists($entity, $getter) && method_exists($entity, $setter)) {
                if ($entity->$getter() === null) {
                    $entity->$setter($primaryId);
                } else {
                    $primaryId = $entity->$getter();
                }
            }
            return $primaryId;
        });
        return $query->insert($fields);
    }
588454
public function insert($entity)
    {
        $entity->set($this->_property, $this->getRoot());

        //only add the entity into the entityset if it has
        //already been loaded
        //otherwise don't
        if ($this->getObject()->isLoaded()) {
            $this->getObject()->insert($entity);
        }

        return $entity;
    }
449706
public function buildInsertQuery($entity) {

        $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity));
        $fields = "";
        $values = "";
        foreach ($mapper->getPropertys() as $property) {
            if ($property->getColumn() != "id") {
                $method = "get" . $property->getName();
                $entity->$method();
                $fields .= "`" . $property->getColumn() . "`, ";
                $values .= "'" . $entity->$method() . "', ";
            }
        }

        $fields = substr_replace($fields, "", -2);
        $values = substr_replace($values, "", -2);

        $query = "INSERT INTO `" . $mapper->getTable() . "` (" . $fields . ") VALUES (" . $values . ");";

        return $query;
    }
397983
public function insert(EntityInterface $entity)
	{
		$sql = <<<EOT
INSERT INTO `$this->tableName` (`Name`, `Description`, `Created`) 
VALUES ( :name , :description , :created )
EOT;

		$stmt = $this->pdo->prepare($sql);
		$stmt->bindParam(':name', $entity->getName(), \PDO::PARAM_STR);
		$stmt->bindParam(':description', $entity->getDescription(), \PDO::PARAM_STR);
		$stmt->bindParam(':created', $entity->getCreatedRfc3339(), \PDO::PARAM_STR);
		$res = $stmt->execute();

		if ($res === false || $stmt->rowCount() !== 1) {
			return false;
		}

		$entity->setProjectId($this->pdo->lastInsertId());

		return $entity;
	}
1315474
public function remove(AbstractEntity $entity)
    {
        for ($i = count($this->registries) - 1; $i >= 0; $i--) {
            /** @var RegistryInterface $registry */
            $registry = $this->registries[ $i ];
            $registry->remove($entity->getId());
        }
    }
1187543
public function insert($entity)
    {
        $values = $this->getInsertValues($entity, $this->namingContention);
        $keyString = implode(array_keys($values), ', ');
        $questionMarkString = count($values) === 0 ? '' : ('?' . str_repeat(', ?', count($values) - 1));

        $sql = "INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)";
        $sth = $this->pdo->prepare($sql);
        $sth->execute(array_values($values));
        $id = $this->pdo->lastInsertId();

        if ($this->idProperty !== null) {
            $this->idProperty->setValue($entity, $id);
        }

        return $id;
    }
529256
public function insert($instance, $entity = null)
    {
        list($instance, $entity) = $this->reassignEntity($instance, $entity);

        return new InsertQuery(
            $this->connection,
            $instance,
            $this->models->get($entity),
            $this->factory,
            $this->accessor,
            $this->dispatcher
        );
    }
1154074
public function persist($entity)
    {
        $entityArray = $this->toArray($entity);
        $instance    = $this->getInstanceFromIdentityMap($entity);

        if ($instance) {
            $this->fillExistingInstanceFromEntityArray($instance, $entityArray);
        }
        if (!$instance) {
            $instance = $this->createInstanceFromEntityArray($entityArray);
        }
        $this->persistanceQueue[] = $instance;

        return $this;
    }
849413
public function insert()
    {
        if ($this->stored) {
            throw new \LogicException("You may not insert an already stored entity");
        }

        $this->callEvent('insert');

        if (empty($this->modified)) {
            return;
        }

        $values = array_intersect_key($this->values, $this->modified);
        $this->connection->insert(static::$table, $values, static::$types);
        //this will only work with some database vendors for now.
        $this->values[static::$primary_key] = $this->connection->lastInsertId();
        $this->setStored();
    }
1137986
public T insert(T entity) {

        if (!hasPrimaryKey(entity)) {
            throw new RuntimeException(String.format("Tried to insert entity of type %s with null or zero primary key",
                    entity.getClass().getSimpleName()));
        }

        InsertCreator insert = new InsertCreator(table);

        insert.setValue(idColumn.getColumnName(), getPrimaryKey(entity));

        if (versionColumn != null) {
            insert.setValue(versionColumn.getColumnName(), 0);
        }

        for (Column column : columns) {
            if (!column.isReadOnly()) {
                insert.setValue(column.getColumnName(), getFieldValueAsColumn(entity, column));
            }
        }

        new JdbcTemplate(ormConfig.getDataSource()).update(insert);

        if (versionColumn != null) {
            ReflectionUtils.setFieldValue(entity, versionColumn.getFieldName(), 0);
        }

        return entity;
    }
998201
public function store($entity)
    {
        if ($this->manager->isTraversable($entity)) {
            return $this->storeCollection($entity);
        } else {
            return $this->storeEntity($entity);
        }
    }
721458
public function insert($entity)
    {
        $persistor = new DoctrinePersistor(
            $this->connection,
            $this->table,
            $this->entityRegistry->getEntityBuilder(),
            $this->entityRegistry
        );
        $persistor->insert($entity);
    }
599094
public function insert($entity)
    {
        $persistor = new CsvPersistor(
            $this->gateway,
            $this->table,
            $this->entityRegistry->getEntityBuilder(),
            $this->entityRegistry
        );
        $persistor->insert($entity);
    }
985453
protected function insertIntoDatabase(Entity $entity)
    {
        $primaryKey = $this->mapper->getPrimaryKey($this->getTable());
        $values = $entity->getModifiedRowData();
        $this->connection->query(
            'INSERT INTO %n %v',
            $this->getTable(),
            $values
        );
        return isset($values[$primaryKey]) ? $values[$primaryKey] : $this->connection->getInsertId();
    }
641998
public function insertAndGet($oEntity)
	{
		$iResult = $this->insert($oEntity);
		
		if ($iResult) { return $this->getLastRow(); }

		return $iResult;
	}