Connection.php

Same filename in this branch
  1. 11.x core/modules/sqlite/src/Driver/Database/sqlite/Connection.php
  2. 11.x core/modules/mysql/src/Driver/Database/mysql/Connection.php
  3. 11.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DriverTestMysql/Connection.php
  4. 11.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DriverTestMysqlDeprecatedVersion/Connection.php
  5. 11.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DriverTestPgsql/Connection.php
  6. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Connection.php
  7. 11.x core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFake/Connection.php
  8. 11.x core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/Connection.php
  9. 11.x core/tests/fixtures/database_drivers/core/CoreFake/Connection.php
  10. 11.x core/tests/fixtures/database_drivers/custom/CoreFake/Connection.php
  11. 11.x core/lib/Drupal/Core/Database/Connection.php
Same filename in other branches
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php
  2. 9 core/modules/mysql/src/Driver/Database/mysql/Connection.php
  3. 9 core/modules/system/tests/modules/database_statement_monitoring_test/src/sqlite/Connection.php
  4. 9 core/modules/system/tests/modules/database_statement_monitoring_test/src/mysql/Connection.php
  5. 9 core/modules/system/tests/modules/database_statement_monitoring_test/src/pgsql/Connection.php
  6. 9 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/Connection.php
  7. 9 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php
  8. 9 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/Connection.php
  9. 9 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php
  10. 9 core/tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefake/Connection.php
  11. 9 core/tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefakeWithAllCustomClasses/Connection.php
  12. 9 core/tests/fixtures/database_drivers/core/corefake/Connection.php
  13. 9 core/tests/fixtures/database_drivers/custom/corefake/Connection.php
  14. 9 core/tests/fixtures/database_drivers/custom/fake/Connection.php
  15. 9 core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
  16. 9 core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
  17. 9 core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
  18. 9 core/lib/Drupal/Core/Database/Connection.php
  19. 8.9.x core/modules/system/tests/modules/database_statement_monitoring_test/src/sqlite/Connection.php
  20. 8.9.x core/modules/system/tests/modules/database_statement_monitoring_test/src/mysql/Connection.php
  21. 8.9.x core/modules/system/tests/modules/database_statement_monitoring_test/src/pgsql/Connection.php
  22. 8.9.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/Connection.php
  23. 8.9.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php
  24. 8.9.x core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/Connection.php
  25. 8.9.x core/tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefake/Connection.php
  26. 8.9.x core/tests/fixtures/database_drivers/core/corefake/Connection.php
  27. 8.9.x core/tests/fixtures/database_drivers/custom/corefake/Connection.php
  28. 8.9.x core/tests/fixtures/database_drivers/custom/fake/Connection.php
  29. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
  30. 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
  31. 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
  32. 8.9.x core/lib/Drupal/Core/Database/Connection.php
  33. 10 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php
  34. 10 core/modules/mysql/src/Driver/Database/mysql/Connection.php
  35. 10 core/modules/system/tests/modules/database_statement_monitoring_test/src/sqlite/Connection.php
  36. 10 core/modules/system/tests/modules/database_statement_monitoring_test/src/mysql/Connection.php
  37. 10 core/modules/system/tests/modules/database_statement_monitoring_test/src/pgsql/Connection.php
  38. 10 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/Connection.php
  39. 10 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysqlDeprecatedVersion/Connection.php
  40. 10 core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/Connection.php
  41. 10 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php
  42. 10 core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFake/Connection.php
  43. 10 core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/Connection.php
  44. 10 core/tests/fixtures/database_drivers/core/CoreFake/Connection.php
  45. 10 core/tests/fixtures/database_drivers/custom/CoreFake/Connection.php
  46. 10 core/tests/fixtures/database_drivers/custom/fake/Connection.php
  47. 10 core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
  48. 10 core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
  49. 10 core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
  50. 10 core/lib/Drupal/Core/Database/Connection.php

Namespace

Drupal\Driver\Database\fake

File

core/tests/fixtures/database_drivers/custom/fake/Connection.php

View source
<?php

namespace Drupal\Driver\Database\fake;

use Drupal\Core\Database\Connection as CoreConnection;
use Drupal\Core\Database\ExceptionHandler;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\Query\Delete;
use Drupal\Core\Database\Query\Insert;
use Drupal\Core\Database\Query\Merge;
use Drupal\Core\Database\Query\Select;
use Drupal\Core\Database\Query\Truncate;
use Drupal\Core\Database\Query\Update;
use Drupal\Core\Database\Query\Upsert;
use Drupal\Core\Database\StatementWrapper;
use Drupal\Core\Database\Transaction;

/**
 * A fake Connection class for testing purposes.
 */
class Connection extends CoreConnection {
    
    /**
     * {@inheritdoc}
     */
    protected $statementClass = NULL;
    
    /**
     * {@inheritdoc}
     */
    protected $statementWrapperClass = StatementWrapper::class;
    
    /**
     * {@inheritdoc}
     */
    protected $identifierQuotes = [
        '"',
        '"',
    ];
    
    /**
     * Public property so we can test driver loading mechanism.
     *
     * @var string
     * @see driver().
     */
    public $driver = 'fake';
    
    /**
     * {@inheritdoc}
     */
    public function queryRange($query, $from, $count, array $args = [], array $options = []) {
        return NULL;
    }
    
    /**
     * {@inheritdoc}
     */
    public function driver() {
        return $this->driver;
    }
    
    /**
     * {@inheritdoc}
     */
    public function databaseType() {
        return 'fake';
    }
    
    /**
     * {@inheritdoc}
     */
    public function createDatabase($database) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function mapConditionOperator($operator) {
        return NULL;
    }
    
    /**
     * {@inheritdoc}
     */
    public function exceptionHandler() {
        return new ExceptionHandler();
    }
    
    /**
     * {@inheritdoc}
     */
    public function select($table, $alias = NULL, array $options = []) {
        return new Select($this, $table, $alias, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function insert($table, array $options = []) {
        return new Insert($this, $table, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function merge($table, array $options = []) {
        return new Merge($this, $table, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function upsert($table, array $options = []) {
        return new Upsert($this, $table, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function update($table, array $options = []) {
        return new Update($this, $table, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function delete($table, array $options = []) {
        return new Delete($this, $table, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function truncate($table, array $options = []) {
        return new Truncate($this, $table, $options);
    }
    
    /**
     * {@inheritdoc}
     */
    public function schema() {
        if (empty($this->schema)) {
            $this->schema = new Schema($this);
        }
        return $this->schema;
    }
    
    /**
     * {@inheritdoc}
     */
    public function condition($conjunction) {
        return new Condition($conjunction, FALSE);
    }
    
    /**
     * {@inheritdoc}
     */
    public function startTransaction($name = '') {
        return new Transaction($this, $name);
    }

}

Classes

Title Deprecated Summary
Connection A fake Connection class for testing purposes.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.