handleStatementException example


  public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE): StatementInterface {
    if (isset($options['return'])) {
      @trigger_error('Passing "return" option to ' . __METHOD__ . '() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520', E_USER_DEPRECATED);
    }

    try {
      $query = $this->preprocessStatement($query$options);
      $statement = new Statement($this->connection, $this$query$options['pdo'] ?? []$allow_row_count);
    }
    catch (\Exception $e) {
      $this->exceptionHandler()->handleStatementException($e$query$options);
    }
    return $statement;
  }

  public function nextId($existing_id = 0) {
    try {
      $this->startTransaction();
    }
    catch (\PDOException $e) {
      // $this->exceptionHandler()->handleExecutionException()       // requires a $statement argument, so we cannot use that.

  public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE): StatementInterface {
    if (isset($options['return'])) {
      @trigger_error('Passing "return" option to ' . __METHOD__ . '() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520', E_USER_DEPRECATED);
    }

    try {
      $query = $this->preprocessStatement($query$options);
      $statement = new $this->statementWrapperClass($this$this->connection, $query$options['pdo'] ?? []$allow_row_count);
    }
    catch (\Exception $e) {
      $this->exceptionHandler()->handleStatementException($e$query$options);
    }

    return $statement;
  }

  /** * Returns a string SQL statement ready for preparation. * * This method replaces table names in curly braces and identifiers in square * brackets with platform specific replacements, appropriately escaping them * and wrapping them with platform quote characters. * * @param string $query * The query string as SQL, with curly braces surrounding the table names, * and square brackets surrounding identifiers. * @param array $options * An associative array of options to control how the query is run. See * the documentation for self::defaultOptions() for details. * * @return string * A string SQL statement ready for preparation. * * @throws \InvalidArgumentException * If multiple statements are included in the string, and delimiters are * not allowed in the query. */
Home | Imprint | This part of the site doesn't use cookies.