Statement example

public function __construct(
        ConnectionInterface $connection,
        private DebugDataHolder $debugDataHolder,
        private ?Stopwatch $stopwatch,
        private string $connectionName,
    ) {
        parent::__construct($connection);
    }

    public function prepare(string $sql): DriverStatement
    {
        return new Statement(
            parent::prepare($sql),
            $this->debugDataHolder,
            $this->connectionName,
            $sql,
            $this->stopwatch,
        );
    }

    public function query(string $sql): Result
    {
        $this->debugDataHolder->addQuery($this->connectionName, $query = new Query($sql));

        
/** * {@inheritdoc} */
  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();
    }
    
public function testDeprecationSelect() {
    $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Select is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492');
    $select = new Select($this->connection, 'test');
    $this->assertInstanceOf(Select::class$select);
  }

  /** * @covers Drupal\Core\Database\Driver\sqlite\Statement */
  public function testDeprecationStatement() {
    $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Statement is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492');
    $statement = new Statement($this->createMock(StubPDO::class)$this->connection, '', []);
    $this->assertInstanceOf(Statement::class$statement);
  }

  /** * @covers Drupal\Core\Database\Driver\sqlite\Truncate */
  public function testDeprecationTruncate() {
    $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Truncate is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492');
    $truncate = new Truncate($this->connection, 'test');
    $this->assertInstanceOf(Truncate::class$truncate);
  }

  
Home | Imprint | This part of the site doesn't use cookies.