### Doctrine DBAL API: Configuration and Cache Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md This API documentation covers methods related to cache configuration within Doctrine DBAL. It details methods for setting and getting cache implementations. ```APIDOC Configuration: setResultCache(Cache $cache): void Sets the cache implementation for query results. Parameters: - cache: An instance of Cache interface. getResultCache(): Cache|null Returns the configured cache implementation for query results. Returns: - Cache|null: The cache implementation or null if not set. QueryCacheProfile: setResultCache(Cache $cache): void Sets the cache implementation for query results for this profile. Parameters: - cache: An instance of Cache interface. getResultCache(): Cache|null Returns the configured cache implementation for query results for this profile. Returns: - Cache|null: The cache implementation or null if not set. ``` -------------------------------- ### Custom Driver Options Example Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/configuration.rst An example of how to pass custom driver options to the PDO constructor, which is equivalent to the fourth argument of the PDO constructor in PHP. ```php $connection = new PDO("mysql:host=localhost;dbname=testdb", "username", "password", [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ]); ``` -------------------------------- ### Table Class Instantiation and Configuration Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Explains that `Table::__construct()` is now internal and recommends using `Table::editor()` to get an editor and `TableEditor::create()` to create a table. It also notes the deprecation of `Table::setSchemaConfig()` and `$_schemaConfig` property, advising to pass `TableConfiguration` to the constructor. ```php Use `Table::editor()` to instantiate an editor and `TableEditor::create()` to create a table. ``` ```php Pass a `TableConfiguration` instance to the constructor instead of using `Table::setSchemaConfig()` or the `$_schemaConfig` property. ``` -------------------------------- ### Doctrine DBAL Upgrade to 3.6: Schema Manager Factory Configuration Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Details the upcoming change in schema manager creation in DBAL 4 and provides an example of how to opt into the new behavior by configuring the schema manager factory. ```php use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; $configuration = new Configuration(); $configuration->setSchemaManagerFactory(new DefaultSchemaManagerFactory()); $connection = DriverManager::getConnection( [/* your parameters */], $configuration ); ``` -------------------------------- ### Doctrine DBAL Upgrade to 3.8: Deprecated QueryBuilder Get Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Covers the deprecation of `QueryBuilder::getQueryPart()` and `::getQueryParts()`, advising against relying on these methods as query parts are implementation details. ```php class QueryBuilder { // getQueryPart() deprecated // getQueryParts() deprecated } ``` -------------------------------- ### Internal OraclePlatform Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Lists OraclePlatform methods that have been marked as internal. ```APIDOC OraclePlatform::getCreateAutoincrementSql() - Marked as internal. OraclePlatform::getDropAutoincrementSql() - Marked as internal. ``` -------------------------------- ### Doctrine DBAL API: QueryBuilder Reset and Get Parts Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md API documentation for methods in `QueryBuilder` related to resetting query parts and retrieving query parts. Note: Retrieving query parts is deprecated. ```APIDOC QueryBuilder: resetQueryParts(): QueryBuilder Resets all query parts. Returns: - QueryBuilder: The QueryBuilder instance for chaining. resetQueryPart(string $queryPartName): QueryBuilder Resets a specific query part. Parameters: - queryPartName: The name of the query part to reset (e.g., 'select', 'where'). Returns: - QueryBuilder: The QueryBuilder instance for chaining. select(string ...$columns): QueryBuilder Sets the SELECT part of the query. Parameters: - columns: The columns to select. Returns: - QueryBuilder: The QueryBuilder instance for chaining. distinct(bool $distinct = true): QueryBuilder Sets the DISTINCT keyword for the query. Parameters: - distinct: Whether to use DISTINCT. Returns: - QueryBuilder: The QueryBuilder instance for chaining. resetWhere(): QueryBuilder Resets the WHERE clause of the query. Returns: - QueryBuilder: The QueryBuilder instance for chaining. resetGroupBy(): QueryBuilder Resets the GROUP BY clause of the query. Returns: - QueryBuilder: The QueryBuilder instance for chaining. resetHaving(): QueryBuilder Resets the HAVING clause of the query. Returns: - QueryBuilder: The QueryBuilder instance for chaining. resetOrderBy(): QueryBuilder Resets the ORDER BY clause of the query. Returns: - QueryBuilder: The QueryBuilder instance for chaining. values(array $values): QueryBuilder Sets the VALUES part of the query. Parameters: - values: An array of values. Returns: - QueryBuilder: The QueryBuilder instance for chaining. getQueryPart(string $queryPartName): mixed Retrieves a specific query part. Deprecated. Parameters: - queryPartName: The name of the query part. Returns: - mixed: The query part. getQueryParts(): array Retrieves all query parts. Deprecated. Returns: - array: An array of query parts. ``` -------------------------------- ### Removed AbstractPlatform::supportsForeignKeyConstraints() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `AbstractPlatform::supportsForeignKeyConstraints()` method has been removed. ```php /** * BC BREAK: removed `AbstractPlatform::supportsForeignKeyConstraints()`. * * The `AbstractPlatform::supportsForeignKeyConstraints()` method has been removed. */ ``` -------------------------------- ### Removed CreateSchemaSqlCollector and DropSchemaSqlCollector Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `CreateSchemaSqlCollector` and `DropSchemaSqlCollector` classes have been removed. ```php /** * BC BREAK: removed `CreateSchemaSqlCollector` and `DropSchemaSqlCollector` * * The `CreateSchemaSqlCollector` and `DropSchemaSqlCollector` classes have been removed. */ ``` -------------------------------- ### Deprecated AbstractAsset Method Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Details on the deprecation of AbstractAsset::getFullQualifiedName() and the recommended alternative. ```APIDOC AbstractAsset::getFullQualifiedName() - Deprecated. Use ::getNamespaceName() and ::getName() instead. ``` -------------------------------- ### Doctrine DBAL API: DSN Parsing Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md API documentation for parsing database URLs into connection parameters using DsnParser. ```APIDOC Tools\DsnParser: __construct(array $mapping = []) Constructs a DsnParser instance. Parameters: - mapping: An array mapping database types to driver names. parse(string $dsn): array Parses a DSN string into connection parameters. Parameters: - dsn: The DSN string. Returns: - array: An array of connection parameters. ``` -------------------------------- ### Doctrine DBAL API: Schema Manager Factory Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md API documentation for configuring the schema manager factory in Doctrine DBAL. ```APIDOC Configuration: setSchemaManagerFactory(SchemaManagerFactory $schemaManagerFactory): void Sets the schema manager factory. Parameters: - schemaManagerFactory: An instance of SchemaManagerFactory. ``` -------------------------------- ### Removed AbstractMySQLPlatform Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `AbstractMySQLPlatform` methods `getColumnTypeSQLSnippets()` and `getDatabaseNameSQL()` have been removed. ```APIDOC AbstractMySQLPlatform::getColumnTypeSQLSnippets() AbstractMySQLPlatform::getDatabaseNameSQL() Removed in version 4.0. ``` -------------------------------- ### Deprecated ConsoleRunner Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `ConsoleRunner` class is deprecated. Users should refer to the Symfony Console documentation for bootstrapping command-line applications. ```APIDOC ConsoleRunner ``` -------------------------------- ### Removed ServerInfoAwareConnection::requiresQueryForServerVersion() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been removed as it was an implementation detail common to all supported drivers. ```php ``` -------------------------------- ### Get DBAL Connection with Parameters Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/configuration.rst Establishes a database connection using an array of connection parameters passed to DriverManager::getConnection(). ```php 'mydb', 'user' => 'user', 'password' => 'secret', 'host' => 'localhost', 'driver' => 'pdo_mysql', ]; $conn = DriverManager::getConnection($connectionParams); ``` -------------------------------- ### Deprecated AbstractPlatform::getName() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Details the deprecation of AbstractPlatform::getName() and recommends using the class name for platform identification. ```APIDOC AbstractPlatform::getName() - Deprecated. Relying on the name of the platform is discouraged. To identify the platform, use its class name. ``` -------------------------------- ### Removed AbstractSchemaManager Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `AbstractSchemaManager` class has had its `getDatabasePlatform()` and `listTableDetails()` methods removed. ```php /** * BC BREAK: removed `AbstractSchemaManager` methods * * The `AbstractSchemaManager::getDatabasePlatform()` and `::listTableDetails()` methods have been removed. */ ``` -------------------------------- ### AbstractPlatform::getLocateExpression Argument Type Change Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The type of the `$start` argument in AbstractPlatform::getLocateExpression() has changed from `string|false` to `?string`. The default value is now `null` instead of `false`. ```APIDOC AbstractPlatform::getLocateExpression(string $str, string $substr, ?string $start = null) ``` -------------------------------- ### Composer Autoload Setup Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/introduction.rst This snippet demonstrates how to include the Composer autoloader to enable class loading for Doctrine DBAL. It requires the 'vendor/autoload.php' file, making Doctrine classes accessible. ```php createQueryBuilder(); ``` -------------------------------- ### Create Schema Manager Instance Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/schema-manager.rst Demonstrates how to create a Schema Manager instance from a Doctrine DBAL connection. ```php createSchemaManager(); ``` -------------------------------- ### Example Implicit Index Creation Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/explanation/implicit-indexes.rst Demonstrates the typical SQL syntax for a DBAL-defined implicit index, prefixed with 'IDX_' and referencing a specific column. ```sql CREATE INDEX IDX_885DBAFAA76ED395 ON posts (user_id) ``` -------------------------------- ### Transaction Nesting Without Savepoints Removed Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Starting a transaction within another transaction using `Doctrine\DBAL\Connection::beginTransaction()` now exclusively uses savepoints. Platforms without savepoint support require application logic rework. ```php /** * BC BREAK: remove support for transaction nesting without savepoints * * Starting a transaction inside another transaction with * `Doctrine\DBAL\Connection::beginTransaction()` now always results in * savepoints being used. * * In case your platform does not support savepoints, you will have to * rework your application logic so as to avoid nested transaction blocks. */ ``` -------------------------------- ### Doctrine DBAL CLI Commands Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/cli-tools.rst Provides an overview of available CLI commands for Doctrine DBAL. This section details the `dbal:run-sql` command and its purpose. ```APIDOC Command: dbal:run-sql Description: Executes arbitrary SQL queries against the database connection. Usage: dbal:run-sql SQL_QUERY [--connection=CONNECTION] Arguments: SQL_QUERY The SQL query to execute. Options: --connection The name of the connection to use (if multiple connections are configured). Example: php bin/console dbal:run-sql "SELECT * FROM users" php bin/console dbal:run-sql "UPDATE products SET price = price * 1.1" --connection=my_other_connection Related Commands: doctrine:ensure-production-settings-configured doctrine:mapping:convert doctrine:generate:entities doctrine:schema:create doctrine:schema:update doctrine:schema:validate doctrine:database:create doctrine:database:drop doctrine:database:import doctrine:database:export doctrine:fixtures:load ``` -------------------------------- ### AbstractPlatform::getSubstringExpression Argument Type Change Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The types of the `$start` and `$length` arguments in AbstractPlatform::getSubstringExpression() have changed from `int` and `?int` to `string` and `?string` respectively. This change requires callers to explicitly format numeric literals as strings. ```APIDOC AbstractPlatform::getSubstringExpression(string $value, string $start, ?string $length = null) ``` -------------------------------- ### Removed Schema and Namespace Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Lists schema- and namespace-related methods that have been removed from `AbstractPlatform` and `AbstractSchemaManager`. This includes methods for listing namespaces and creating schemas. ```APIDOC AbstractPlatform: getListNamespacesSQL(): removed AbstractSchemaManager: createSchema(): removed listNamespaceNames(): removed getPortableNamespacesList(): removed getPortableNamespaceDefinition(): removed PostgreSQLSchemaManager: getSchemaNames(): removed ``` -------------------------------- ### Deprecated Transaction Nesting Without Savepoints Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Starting a transaction within another transaction using `Doctrine\DBAL\Connection::beginTransaction()` without enabling transaction nesting with savepoints is deprecated. Enable nesting with `$connection->setNestTransactionsWithSavepoints(true);`. If savepoints are not supported, rework application logic to avoid nested transactions. ```php /* Deprecated: Transaction nesting without savepoints */ // Enable nesting: $connection->setNestTransactionsWithSavepoints(true); ``` -------------------------------- ### Integrate dbal:run-sql Command in Symfony Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/cli-tools.rst Demonstrates how to add the `dbal:run-sql` command to a Symfony console application using the `SingleConnectionProvider`. This snippet shows the necessary imports and instantiation for integrating the command. ```php use Doctrine\DBAL\Connection; use Doctrine\DBAL\Tools\Console\ConnectionProvider\SingleConnectionProvider; use Symfony\Component\Console\Application; /** @var Connection $connection */ $connection = /* ... */; /** @var Application $cli */ $cli = /* ... */; $connectionProvider = new SingleConnectionProvider($connection); $cli->add(new RunSqlCommand($connectionProvider)); ``` -------------------------------- ### Doctrine DBAL DriverException Constructor Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Highlights that the constructor for `Doctrine\DBAL\Exception\DriverException` is now marked as `@internal`, indicating it should not be used directly by external code. ```APIDOC Doctrine\DBAL\Exception\DriverException::__construct() Description: The constructor for `DriverException` is now `@internal`. This means it is intended for internal use within the DBAL library and should not be called directly from application code. ``` -------------------------------- ### SQL Injection - Unsafe String Concatenation Example Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/security.rst Demonstrates a common and dangerous practice of building SQL queries by concatenating user input directly, which is highly vulnerable to SQL injection attacks. This example shows how an attacker can manipulate the query. ```php select('id', 'name') ->from('users'); ``` -------------------------------- ### Removed AbstractSchemaManager::getSchemaSearchPaths() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `getSchemaSearchPaths()` method has been removed from `AbstractSchemaManager`. Schema configuration and creation now reflect platform-specific schema support. ```php // class AbstractSchemaManager { // // public function getSchemaSearchPaths(): array {} // } ``` -------------------------------- ### Removed Console Runner Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `doctrine-dbal` binary and the `ConsoleRunner` class have been removed. Documentation is available for bootstrapping console tools for standalone usage. -------------------------------- ### Removed Graphviz Visitor Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `DoctrineDBALSchemaVisitorGraphviz` class has been removed. -------------------------------- ### Deprecated OraclePlatform::assertValidIdentifier() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Details the deprecation of OraclePlatform::assertValidIdentifier(). ```APIDOC OraclePlatform::assertValidIdentifier() - Deprecated. ``` -------------------------------- ### Internal Platform and Schema Manager Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The following methods are considered internal implementation details and are marked as such: `AbstractMySQLPlatform::getColumnTypeSQLSnippet()`, `AbstractMySQLPlatform::fetchTableOptionsByTable()`, `MariaDB1010Platform::fetchTableOptionsByTable()`, `MariaDBPlatform::getColumnTypeSQLSnippet()`, `OraclePlatform::getCreateAutoincrementSql()`, `OraclePlatform::getIdentitySequenceName()`, `OracleSchemaManager::dropAutoincrement()`, `SQLServerPlatform::getCreateColumnCommentSQL()`, `SQLServerPlatform::getDefaultConstraintDeclarationSQL()`, `SQLServerPlatform::getAlterColumnCommentSQL()`, `SQLServerPlatform::getDropColumnCommentSQL()`, `SQLServerPlatform::getAddExtendedPropertySQL()`, `SQLServerPlatform::getDropExtendedPropertySQL()`, `SQLServerPlatform::getUpdateExtendedPropertySQL()`. ```php // These methods should not be called directly from user code: // AbstractMySQLPlatform::getColumnTypeSQLSnippet() // AbstractMySQLPlatform::fetchTableOptionsByTable() // MariaDB1010Platform::fetchTableOptionsByTable() // MariaDBPlatform::getColumnTypeSQLSnippet() // OraclePlatform::getCreateAutoincrementSql() // OraclePlatform::getIdentitySequenceName() // OracleSchemaManager::dropAutoincrement() // SQLServerPlatform::getCreateColumnCommentSQL() // SQLServerPlatform::getDefaultConstraintDeclarationSQL() // SQLServerPlatform::getAlterColumnCommentSQL() // SQLServerPlatform::getDropColumnCommentSQL() // SQLServerPlatform::getAddExtendedPropertySQL() // SQLServerPlatform::getDropExtendedPropertySQL() // SQLServerPlatform::getUpdateExtendedPropertySQL() ``` -------------------------------- ### Removed Type::canRequireSQLConversion() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `Type::canRequireSQLConversion()` method has been removed. -------------------------------- ### ServerInfoAwareConnection Interface Update Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `ServerInfoAwareConnection` interface now extends the `Connection` interface. Implementations must also implement the methods defined in `Connection`. ```php // interface ServerInfoAwareConnection extends Connection ``` -------------------------------- ### Removed AbstractPlatform::prefersIdentityColumns() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `AbstractPlatform::prefersIdentityColumns()` method has been removed. -------------------------------- ### Running Integration Tests against MySQL Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/testing.rst This snippet demonstrates how to execute integration tests against a MySQL database using a specific PHPUnit configuration file. It requires the pdo_mysql extension to be enabled. ```console php -c ci/github/pdo_mysql.xml ``` -------------------------------- ### VersionAwarePlatformDriver Interface Update Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `VersionAwarePlatformDriver` interface now extends the `Driver` interface. Implementations must also implement the methods defined in `Driver`. ```php // interface VersionAwarePlatformDriver extends Driver ``` -------------------------------- ### Building INSERT, UPDATE, and DELETE Queries Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/query-builder.rst Demonstrates how to initiate INSERT, UPDATE, and DELETE queries by specifying the target table name using insert(), update(), and delete() methods respectively. ```php insert('users') ; $queryBuilder ->update('users') ; $queryBuilder ->delete('users') ; ``` -------------------------------- ### Doctrine DBAL Resource Links Source: https://github.com/doctrine/dbal/blob/4.3.x/README.md Provides links to external resources for Doctrine DBAL, including its official website, documentation, and issue tracker. ```markdown * [Website](http://www.doctrine-project.org/projects/dbal.html) * [Documentation](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/) * [Issue Tracker](https://github.com/doctrine/dbal/issues) ``` -------------------------------- ### DBALException::invalidTableName Replacement Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md `DBALException::invalidTableName()` has been replaced by the `InvalidTableName` class. ```php ``` -------------------------------- ### Doctrine DBAL Version-Specific Links Source: https://github.com/doctrine/dbal/blob/4.3.x/README.md Contains markdown links to specific versions and build information for Doctrine DBAL, including GitHub repository branches, CodeCov reports, AppVeyor builds, and GitHub Actions. ```markdown [Coverage 5.0 image]: https://codecov.io/gh/doctrine/dbal/branch/5.0.x/graph/badge.svg [5.0]: https://github.com/doctrine/dbal/tree/5.0.x [CodeCov 5.0]: https://codecov.io/gh/doctrine/dbal/branch/5.0.x [AppVeyor 5.0]: https://ci.appveyor.com/project/doctrine/dbal/branch/5.0.x [AppVeyor 5.0 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/5.0.x?svg=true [GA 5.0]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A5.0.x [GA 5.0 image]: https://github.com/doctrine/dbal/actions/workflows/continuous-integration.yml/badge.svg?branch=5.0.x [Coverage 4.4 image]: https://codecov.io/gh/doctrine/dbal/branch/4.4.x/graph/badge.svg [4.4]: https://github.com/doctrine/dbal/tree/4.4.x [CodeCov 4.4]: https://codecov.io/gh/doctrine/dbal/branch/4.4.x [AppVeyor 4.4]: https://ci.appveyor.com/project/doctrine/dbal/branch/4.4.x [AppVeyor 4.4 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/4.4.x?svg=true [GA 4.4]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A4.4.x [GA 4.4 image]: https://github.com/doctrine/dbal/actions/workflows/continuous-integration.yml/badge.svg?branch=4.4.x [Coverage 4.3 image]: https://codecov.io/gh/doctrine/dbal/branch/4.3.x/graph/badge.svg [4.3]: https://github.com/doctrine/dbal/tree/4.3.x [CodeCov 4.3]: https://codecov.io/gh/doctrine/dbal/branch/4.3.x [AppVeyor 4.3]: https://ci.appveyor.com/project/doctrine/dbal/branch/4.3.x [AppVeyor 4.3 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/4.3.x?svg=true [GA 4.3]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A4.3.x [GA 4.3 image]: https://github.com/doctrine/dbal/actions/workflows/continuous-integration.yml/badge.svg?branch=4.3.x [Coverage 3.10 image]: https://codecov.io/gh/doctrine/dbal/branch/3.10.x/graph/badge.svg [3.10]: https://github.com/doctrine/dbal/tree/3.10.x [CodeCov 3.10]: https://codecov.io/gh/doctrine/dbal/branch/3.10.x [AppVeyor 3.10]: https://ci.appveyor.com/project/doctrine/dbal/branch/3.10.x [AppVeyor 3.10 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/3.10.x?svg=true [GA 3.10]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A3.10.x [GA 3.10 image]: https://github.com/doctrine/dbal/actions/workflows/continuous-integration.yml/badge.svg?branch=3.10.x ``` -------------------------------- ### Internal SQLServerPlatform Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Identifies methods in SQLServerPlatform that are marked as internal. ```APIDOC SQLServerPlatform::getDefaultConstraintDeclarationSQL() - Marked as internal. SQLServerPlatform::getAddExtendedPropertySQL() - Marked as internal. SQLServerPlatform::getDropExtendedPropertySQL() - Marked as internal. SQLServerPlatform::getUpdateExtendedPropertySQL() - Marked as internal. ``` -------------------------------- ### Deprecated Schema and Namespace Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Lists deprecated methods related to schema and namespace management, recommending the use of `AbstractSchemaManager::listSchemaNames()` as a replacement for several older methods. ```php AbstractPlatform::getListNamespacesSQL() deprecated AbstractSchemaManager::listNamespaceNames() deprecated AbstractSchemaManager::getPortableNamespacesList() deprecated AbstractSchemaManager::getPortableNamespaceDefinition() deprecated PostgreSQLSchemaManager::getSchemaNames() deprecated Use AbstractSchemaManager::listSchemaNames() instead. ``` -------------------------------- ### Removed TableGenerator Component Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The entire TableGenerator component has been removed from the library. ```php // Removed: TableGenerator component ``` -------------------------------- ### Removed OraclePlatform::assertValidIdentifier() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `assertValidIdentifier()` method has been removed from the `OraclePlatform` class. ```php // class OraclePlatform extends AbstractPlatform { // // public function assertValidIdentifier(string $identifier): void {} // } ``` -------------------------------- ### Removed Schema::getTableNames() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `getTableNames()` method has been removed from the `Schema` class. ```php // class Schema { // // public function getTableNames(): array {} // } ``` -------------------------------- ### ConsoleRunner::printCliConfigTemplate() Deprecation Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `ConsoleRunner::printCliConfigTemplate()` method is deprecated as it was primarily useful for the standalone `doctrine-dbal` binary. Refer to the documentation for bootstrapping console tools for standalone usage. ```php // Deprecated: ConsoleRunner::printCliConfigTemplate() ``` -------------------------------- ### Removed AbstractAsset::getFullQualifiedName() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `getFullQualifiedName()` method has been removed from the `AbstractAsset` class. ```php // abstract class AbstractAsset { // // public function getFullQualifiedName(): string {} // } ``` -------------------------------- ### Prepare and Execute Query Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/data-retrieval-and-manipulation.rst Illustrates the process of preparing an SQL statement and then executing it to fetch associative results. ```php $statement = $conn->prepare('SELECT * FROM user'); $resultSet = $statement->executeQuery(); $users = $resultSet->fetchAllAssociative(); ``` -------------------------------- ### Removed SqliteSchemaManager Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `createDatabase()` and `dropDatabase()` methods have been removed from `SqliteSchemaManager`. ```php // class SqliteSchemaManager { // // public function createDatabase(): void {} // // public function dropDatabase(): void {} // } ``` -------------------------------- ### Doctrine DBAL Connection and Querying Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/data-retrieval-and-manipulation.rst Provides an overview of establishing a database connection using `DriverManager::getConnection()` and executing queries. It highlights the importance of parameterization to prevent SQL injection. ```APIDOC Doctrine\DBAL\DriverManager::getConnection(array $params, Doctrine\DBAL\Configuration $config = null) - Establishes a database connection. - Parameters: - params: An array of connection parameters (e.g., driver, host, dbname, user, password). - config: Optional configuration object. - Returns: A Doctrine\DBAL\Connection instance. Doctrine\DBAL\Connection::executeQuery(string $sql) - Executes a SQL query and returns a statement object. - Parameters: - sql: The SQL query string to execute. - Returns: A Doctrine\DBAL\Result object. - Drawbacks: Vulnerable to SQL injection if parameters are not handled properly; tedious quoting; no prepared statement optimization. Doctrine\DBAL\Connection::prepare(string $sql) - Prepares an SQL statement for execution. - Parameters: - sql: The SQL query string with placeholders. - Returns: A Doctrine\DBAL\Statement object. Doctrine\DBAL\Statement::bindValue(int|string $param, mixed $value, int $type = PDO::PARAM_STR) - Binds a value to a placeholder in a prepared statement. - Parameters: - param: The placeholder identifier (positional integer or named string). - value: The value to bind. - type: The PDO data type of the parameter (defaults to PDO::PARAM_STR). Doctrine\DBAL\Statement::executeQuery() - Executes the prepared statement. - Returns: A Doctrine\DBAL\Result object. Doctrine\DBAL\Result::fetchAssociative(): array|false - Fetches the next row from the result set as an associative array. - Returns: An associative array representing the row, or false if no more rows are available. SQL Injection Prevention: - Use prepared statements with placeholders (`?` or `:name`). - Avoid concatenating user input directly into SQL queries. - Use `bindValue()` to safely bind parameters. Placeholder Types: - Positional: `?` - parameters are bound in order. - Named: `:name` - parameters are bound by their name. - Cannot mix positional and named placeholders in the same query. ``` -------------------------------- ### Removed RemoveNamespacedAssets Schema Visitor Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `RemoveNamespacedAssets` schema visitor has been removed. ```php /** * BC BREAK: removed `RemoveNamespacedAssets`. * * The `RemoveNamespacedAssets` schema visitor has been removed. */ ``` -------------------------------- ### Doctrine DBAL Supported Drivers Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/configuration.rst Lists the database drivers currently available for use with Doctrine DBAL, including PDO and native extensions for various database systems. ```APIDOC Available Drivers: - pdo_mysql: MySQL driver using pdo_mysql PDO extension. - mysqli: MySQL driver using mysqli extension. - pdo_sqlite: SQLite driver using pdo_sqlite PDO extension. - sqlite3: SQLite driver using sqlite3 extension. - pdo_pgsql: PostgreSQL driver using pdo_pgsql PDO extension. - pgsql: PostgreSQL driver using pgsql extension. - pdo_oci: Oracle driver using pdo_oci PDO extension (oci8 preferred). - pdo_sqlsrv: Microsoft SQL Server driver using pdo_sqlsrv PDO. - sqlsrv: Microsoft SQL Server driver using sqlsrv PHP extension. - oci8: Oracle driver using oci8 PHP extension. - ibm_db2: IBM DB2 driver using ibm_db2 PHP extension. Custom Driver: - driverClass: Specifies a custom driver implementation. ``` -------------------------------- ### Removed Legacy Execute and Fetch Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The legacy `Result::fetch()`, `Result::fetchAll()`, `Connection::exec()`, `Connection::executeUpdate()`, `Connection::query()`, and the `FetchMode` class have been removed. ```APIDOC Result::fetch() Result::fetchAll() Connection::exec() Connection::executeUpdate() Connection::query() FetchMode class Removed in version 4.0. ``` -------------------------------- ### Deprecated Sequence Method Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Highlights the deprecation of the `Sequence::isAutoIncrementsFor()` method. ```php The `Sequence::isAutoIncrementsFor()` method has been deprecated. ``` -------------------------------- ### SQL Prepared Statements - Positional Placeholder Example Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/security.rst Shows the correct and secure way to handle user input in SQL queries using prepared statements with positional placeholders (question marks). This method separates the SQL query from the data, preventing injection. ```php prepare($sql); $stmt->bindValue(1, $_GET['username']); $resultSet = $stmt->executeQuery(); ``` -------------------------------- ### Doctrine DBAL Upgrade to 3.5: Deprecated Extension via Connection Events Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Covers the deprecation of subscribing to the `postConnect` event and suggests using custom middleware or specific middleware implementations as replacements. ```php // Deprecated postConnect event listeners: // 1. OracleSessionInit -> Use Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession // 2. SQLiteSessionInit -> Use Doctrine\DBAL\Driver\AbstractSQLiteDriver\Middleware\EnableForeignKeys // 3. SQLSessionInit -> Implement custom middleware ``` -------------------------------- ### Deprecated Table Method Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Indicates the deprecation of the Table::columnsAreIndexed() method. ```php Table::columnsAreIndexed() ``` -------------------------------- ### Doctrine DBAL Core Components Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/architecture.rst Describes the main components of the DBAL: Connection, Statement, and Result, and how they wrap driver-specific interfaces. ```php namespace Doctrine\DBAL { interface Connection {} interface Statement {} interface Result {} } namespace Doctrine\DBAL\Driver { interface Connection {} interface Statement {} interface Result {} interface Driver {} interface Middleware {} } ``` -------------------------------- ### Removed MsSQLKeywords Class Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `DoctrineDBALPlatformsMsSQLKeywords` class has been removed. Use `DoctrineDBALPlatformsSQLServerPlatform` instead. ```php // Use Doctrine\DBAL\Platforms\SQLServerPlatform instead of MsSQLKeywords ``` -------------------------------- ### Removed EchoSQLLogger Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `EchoSQLLogger` class is no longer part of the Doctrine DBAL package. ```php // EchoSQLLogger is no longer available. ``` -------------------------------- ### PostgreSQL Server Version Detection Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/configuration.rst Illustrates how to get the PostgreSQL server version using the SHOW server_version command. This information is used by Doctrine DBAL to select the appropriate platform implementation. ```sql SHOW server_version; ``` -------------------------------- ### BC BREAK: Doctrine\DBAL\DBALException Renamed Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The exception class `Doctrine\DBAL\DBALException` has been renamed to `Doctrine\DBAL\Exception`. ```php BC BREAK: Doctrine\DBAL\DBALException class renamed to Doctrine\DBAL\Exception. ``` -------------------------------- ### Removed Schema Comparison APIs Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The Schema::getMigrateFromSql() and Schema::getMigrateToSql() methods have been removed. These APIs are no longer supported as they did not account for the current database connection and platform. ```php // Removed: public function getMigrateFromSql(Schema $toSchema, Schema $fromSchema): array // Removed: public function getMigrateToSql(Schema $fromSchema, Schema $toSchema): array ``` -------------------------------- ### Internal OracleSchemaManager Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Marks a specific method within `OracleSchemaManager` as internal. ```php OracleSchemaManager::dropAutoincrement() marked internal ``` -------------------------------- ### SQL Server (sqlsrv) Connection Parameters Source: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/configuration.rst Outlines the basic connection parameters for the SQL Server (sqlsrv) driver in Doctrine DBAL, including username, password, and host. ```APIDOC SQL Server (sqlsrv) Connection Parameters: user (string): Username for database connection. password (string): Password for database connection. host (string): Hostname of the database. ``` -------------------------------- ### Deprecated SqliteSchemaManager Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Details the deprecation of SqliteSchemaManager::createDatabase() and dropDatabase() methods. ```APIDOC SqliteSchemaManager::createDatabase() - Deprecated. The SQLite engine will create the database file automatically. In order to delete the database file, use the filesystem. SqliteSchemaManager::dropDatabase() - Deprecated. The SQLite engine will create the database file automatically. In order to delete the database file, use the filesystem. ``` -------------------------------- ### QueryBuilder API Changes Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Outlines significant changes to the `QueryBuilder` API. Methods like `select()`, `addSelect()`, `groupBy()`, and `addGroupBy()` now require individual arguments or expansion using the `...` operator, and no longer ignore empty first arguments. `insert()`, `update()`, and `delete()` require the `$table` parameter and do not support aliases. Several methods (`add`, `getQueryPart`, etc.) have been removed. `getSQL()` for select queries throws an exception if no select expressions are provided. ```APIDOC QueryBuilder: select(...$expressions): QueryBuilder Adds expressions to the SELECT clause. Accepts individual arguments or expanded arrays. addSelect(...$expressions): QueryBuilder Adds expressions to the SELECT clause. groupBy(...$expressions): QueryBuilder Adds expressions to the GROUP BY clause. addGroupBy(...$expressions): QueryBuilder Adds expressions to the GROUP BY clause. insert(string $table): QueryBuilder Sets the table for an INSERT statement. Aliases are not supported. update(string $table): QueryBuilder Sets the table for an UPDATE statement. Aliases are not supported. delete(string $table): QueryBuilder Sets the table for a DELETE statement. Aliases are not supported. add(): removed getQueryPart(): removed getQueryParts(): removed resetQueryPart(): removed resetQueryParts(): removed getSQL(): string Returns the generated SQL query. Throws an exception if no SELECT expressions are provided for a SELECT query. ``` -------------------------------- ### Doctrine DBAL API: Parameter Type Constants Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md API documentation for parameter type constants in Doctrine DBAL, including array parameter types. ```APIDOC ParameterType: INTEGER: int STRING: int ... (other parameter types) ArrayParameterType: INTEGER: int STRING: int ... (other array parameter types) ``` -------------------------------- ### Doctrine DBAL Driver::getName() Removal Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Documents the removal of the Doctrine\DBAL\Driver::getName() method. ```php // Removed: Doctrine\DBAL\Driver::getName() ``` -------------------------------- ### Deprecated Visitor Interfaces and Schema Visit Methods Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Visitor interfaces (`Visitor`, `NamespaceVisitor`, `AbstractVisitor`) and the `visit()` methods on schema objects (`Schema::visit()`, `Table::visit()`, `Sequence::visit()`) are deprecated. The recommended approach is to call the API of the schema objects directly rather than using the visitor pattern. ```APIDOC Visitor NamespaceVisitor AbstractVisitor Schema: visit(Visitor $visitor) Table: visit(Visitor $visitor) Sequence: visit(Visitor $visitor) ``` -------------------------------- ### Removed ColumnDiff::hasChanged() Method Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The ColumnDiff::hasChanged() method has been removed from the ColumnDiff class. ```php // Removed method: ColumnDiff::hasChanged() ``` -------------------------------- ### Removed $createFlags from AbstractPlatform::getCreateTableSQL() Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `$createFlags` parameter has been removed from the `AbstractPlatform::getCreateTableSQL()` method. ```php /** * BC BREAK: removed `$createFlags` from `AbstractPlatform::getCreateTableSQL()` * * The `$createFlags` parameter of `AbstractPlatform::getCreateTableSQL()` has been removed. */ ``` -------------------------------- ### Removed Driver::getSchemaManager() Method Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `Driver::getSchemaManager()` method has been removed from the `Driver` interface. ```php /** * BC BREAK: removed `Driver::getSchemaManager()` * * The `Driver::getSchemaManager()` method has been removed. */ ``` -------------------------------- ### Doctrine DBAL API: MySQL Platform SQL Snippets Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md API documentation for methods related to generating SQL snippets for column types in MySQL platform implementations. ```APIDOC AbstractMySQLPlatform: getColumnTypeSQLSnippet(string $databaseName = null): string Returns the SQL snippet for a column type. Parameters: - databaseName: The name of the database (optional). Returns: - string: The SQL snippet for the column type. getDatabaseNameSQL(): string Returns the SQL snippet to get the database name. Returns: - string: The SQL snippet to get the database name. ``` -------------------------------- ### Removed DoctrineDBALVersion Class Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md The `DoctrineDBALVersion` class has been removed. Checking the DBAL version at runtime is discouraged. ```php // The Doctrine\DBAL\Version class is no longer available. ``` -------------------------------- ### Doctrine DBAL MasterSlaveConnection Removal Source: https://github.com/doctrine/dbal/blob/4.3.x/UPGRADE.md Announces the removal of the MasterSlaveConnection class, which has been deprecated in favor of PrimaryReadReplicaConnection. ```php // Removed: MasterSlaveConnection // Use: PrimaryReadReplicaConnection instead. ```