Skip to content

Increment or insert if value is not defined #2

@obukhov

Description

@obukhov

If I specify:

/** @var QueryInterface $query **/
$c = new Criteria('table');
$c->write(['name' => 'foobar', 'counter' => 1])
  ->upsert(['counter']);

$query->increment($c);

I would like insert-or-increment sql query like this:

INSERT INTO table (`name`, `counter`) VALUES ('foobar', 1)
ON DUPLICATE KEY UPDATE  counter = counter + 1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions