CRUDlex\MySQLData::update PHP Method

update() public method

public update ( Entity $entity )
$entity Entity
    public function update(Entity $entity)
    {
        if (!$this->shouldExecuteEvents($entity, 'before', 'update')) {
            return false;
        }
        $queryBuilder = $this->database->createQueryBuilder();
        $queryBuilder->update('`' . $this->definition->getTable() . '`')->set('updated_at', 'UTC_TIMESTAMP()')->set('version', 'version + 1')->where('id = ?')->setParameter(count($this->getFormFields()), $entity->get('id'));
        $this->setValuesAndParameters($entity, $queryBuilder, 'set');
        $affected = $queryBuilder->execute();
        $this->saveMany($entity);
        $this->shouldExecuteEvents($entity, 'after', 'update');
        return $affected;
    }