Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2.6
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      We are missing Insert and Merge Query Objects.

      See Drupal DBTNG:

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

        Issue Links

          Activity

          Hide
          Benjamin Eberlei added a comment -

          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.

          Show
          Benjamin Eberlei added a comment - 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.

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Benjamin Eberlei
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: