Back to Drupal Training Syllabus
Drupal Database API Basics
The course covers the basics of database functions.
Learning Objective
Trainee will be able to do all the basic database transactions, like select, insert, update and delete.
Course Content
-
Introduction
-
Create DB
-
Select, Insert, Update, Delete
-
Database Abstraction Layer
-
Query optimization
Database API provides a standard, vendor-agnostic abstraction layer for accessing database servers.
https://www.drupal.org/developing/api/database
In Drupal 7 and earlier versions before running the installation script, developer must create an empty database and database user.
Since 8.x, it is not necessary to create a database before installing Drupal. Now, the specified database name will be created at the time of Drupal installation if it doesn't already exist.
https://www.drupal.org/documentation/install/create-database
Drupal's database abstraction layer provides a unified database query API that can query different underlying databases. It is built upon PHP's PDO (PHP Data Objects) database API, and inherits much of its syntax and semantics. Besides providing a unified API for database queries, the database abstraction layer also provides a structured way to construct complex queries, and it protects the database by using good security practices.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!database.api.php/group/database/8
Drupal provides a database abstraction layer to provide developers with the ability to support multiple database servers easily. The intent of this layer is to preserve the syntax and power of SQL as much as possible, but also allow developers a way to leverage more complex functionality in a unified way. It also provides a structured interface for dynamically constructing queries when appropriate, and enforcing security checks and similar good practices.
http://praxent.com/blog/introduction-to-drupals-database-abstraction-lay...
In order to increase the performance of Drupal website, it is important to optimize the query.
https://drupalwatchdog.com/volume-4/issue-1/mysql-query-optimization
Reference
https://buildamodule.com/video/drupal-7-development-core-concepts-how-to...
https://www.drupal.org/node/811594