Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL-182: Insert and Merge Query Objects #1349

Closed
doctrinebot opened this issue Nov 18, 2011 · 4 comments
Closed

DBAL-182: Insert and Merge Query Objects #1349

doctrinebot opened this issue Nov 18, 2011 · 4 comments

Comments

@doctrinebot
Copy link

Jira issue originally created by user @beberlei:

We are missing Insert and Merge Query Objects.

See Drupal DBTNG:

Merge: http://drupal.org/node/310085
Insert: http://drupal.org/node/310079

@doctrinebot
Copy link
Author

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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:

  • Difference compared to QueryBuilder is that these objects are no builders, but actually executors.
  • Don't assume Literals
  • Creation is delegated to Platform (Runtime API of a Vendor)

{conn}
$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.

@doctrinebot doctrinebot added this to the 2.6 milestone Dec 6, 2015
@Ocramius Ocramius assigned Ocramius and unassigned beberlei Jun 29, 2017
@Ocramius Ocramius removed this from the 2.6 milestone Jun 29, 2017
@Ocramius
Copy link
Member

This won't happen - the proposed API doesn't really make sense to me, and we should instead have UPSERT as in #1320

Closing.

@github-actions
Copy link

github-actions bot commented Aug 5, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants