Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-278

add support for lastInsertId method on OCI8 Driver

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.3
    • Component/s: Drivers
    • Labels:
      None
    • Environment:
      oci8

      Description

      The method lastInsertId() is not defined for OCI8 Driver in Doctrine\DBAL\Driver\OCI8\OCI8Connection.php :

      OCI8Connection.php
      public function lastInsertId($name = null)
      {
          //TODO: throw exception or support sequences?
      }
      

      I propose this method to handle lastInsertId for sequence :

      OCI8Connection.php
      public function lastInsertId($name = null)
       {
              // For sequence
              if (is_string($name)) {
                  // We can check eventually check the presence of the sequence in the table
                  // USER_SEQUENCES
                  $sql = 'SELECT ' . $name . '.CURRVAL FROM DUAL';
                  // will throw an exception if this sequence does not exist
                  $stmt = $this->query($sql);
                  $result = $stmt->fetch(\PDO::FETCH_ASSOC);
                  if ($result !== false && isset($result['CURRVAL'])) {
                      return (int) $result['CURRVAL'];
                  }
          }
          // OCI8 driver does not provide support of lastInsertId
          return null;
      }
      

      Thanks,

        Activity

        Franek created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.3 [ 10184 ]
        Fix Version/s 2.2.3 [ 10210 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 13702 ] jira-feedback2 [ 17832 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17832 ] jira-feedback3 [ 20187 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-278, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated:
              Resolved: