[DBAL-182] Insert and Merge Query Objects Created: 18/Nov/11 Updated: 20/Sep/12 |
|
| Status: | Open |
| Project: | Doctrine DBAL |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
We are missing Insert and Merge Query Objects. See Drupal DBTNG: Merge: http://drupal.org/node/310085 |
| Comments |
| Comment by Benjamin Eberlei [ 18/Nov/11 ] |
|
From the first glance: Drupal API has some problems in that it assumes literal values are the default, which makes working with them simple if no expression is necessary. But inconsistent otherwise. Implementation Details:
$conn->createInsertQuery(); $conn->createMergeQuery();{conn} Sample API: $conn->createInsertQuery($tbl)->fields(array('foo', 'bar'))->values(array('?', '?'))->(array(1, 2))->execute();
$conn->createInsertQuery($tbl)->fields(array('foo', 'bar'))->params(array(1, 2))->execute(); // values(?, ?) is implicit.
$conn->createInsertQuery($tbl)->fields(array('foo', 'bar'))->params(array('NOW()', '1'))->execute(); // if no "params" set assume execute once.
$conn->createInsertQuery($tbl)->fields(array('foo', 'bar'))->value('foo', 'NOW())->params(array(1))->params(array(2))->execute();
$conn->createInsertQuery($tbl)->fields(array('foo', 'bar'))->select($queryBuilder)->execute();
Merge: I dont know yet: problem i see here is that people mistake values() for a "safe" method and pass values in there that should be quoted instead. |