Issue #2991337: How to get database connection in the code? Which method is recomended?
Merge request reports
Activity
added 590 commits
-
c0ee7c56...4894881a - 589 commits from branch
project:9.3.x
- f655c94d - Apply #34 patch
-
c0ee7c56...4894881a - 589 commits from branch
- Resolved by Oleh Vehera
225 225 * @endcode 226 226 * if you had a connection object variable $connection available to use. See 227 227 * also the @link container Services and Dependency Injection topic. @endlink 228 * In Object Oriented code: 229 * - If possible, use dependency injection to use @database service or 230 * $container->get('database'); to inject the database connection; 231 * - If it is not possible to use dependency injection, e.g. in a static 232 method, use \Drupal::database(); 233 * @code 234 * $connection = \Drupal::database(); 235 * $query = $connection->query('...'); 236 * @endcode 237 * - If services are not yet available, 238 * \Drupal\Core\Database\Database::getConnection() can get a database changed this line in version 13 of the diff
- Resolved by Oleh Vehera
added 2584 commits
-
9af23ab9...1aaa480b - 2582 commits from branch
project:11.x
- 04bd0820 - Apply #34 patch
- 40e65f2d - Address #42
-
9af23ab9...1aaa480b - 2582 commits from branch
- Resolved by Oleh Vehera
- Resolved by Oleh Vehera
Please register or sign in to reply