Skip to content

[NFR] Query\Builder support INSERT/UPDATE/DELETE #1925

Description

@iwai

I tried to think of a new method, but how about you??

# INSERT INTO Cars (price, type) VALUES (:price:, :type:)
$result = $this->modelsManager->createBuilder()
   ->insert('Cars', array('price' => 15000.00, 'type' => 'Sedan'))
   ->getQuery()
   ->execute();

# UDPATE Cars SET price = :price, type = :type: WHERE id = :id:
$result = $this->modelsManager->createBuilder()
   ->update('Cars', array('price' => 15000.00, 'type' => 'Sedan'))
   ->where('id = :id:', array('id' => 100))
   ->getQuery()
   ->execute();

# DELETE FROM Cars WHERE id = :id:
$result = $this->modelsManager->createBuilder()
   ->delete('Cars')
   ->where('id = :id:', array('id' => 100))
   ->getQuery()
   ->execute();

## Or alternate concept

# INSERT INTO Cars (price, type) VALUES (:price:, :type:)
$result = $this->modelsManager->createBuilder()
   ->insert('Cars', array('price', 'type'), array(15000.00, 'Sedan'))
   ->getQuery()
   ->execute();

# UDPATE Cars SET price = :price, type = :type: WHERE id = :id:
$result = $this->modelsManager->createBuilder()
   ->update('Cars', array('price', 'type'), array(15000.00, 'Sedan'))
   ->where('id = :id:', array('id' => 100))
   ->getQuery()
   ->execute();

Method return is Phalcon\Mvc\Model\Query\Status.

I'm afraid my expressions may be rude or hard to read, because I'm not so good at English.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleStale issue - automatically closed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions