Blogz

Recent Blogz

Drupal : Programatically Accessing Entity information - entity_get_info()

Entity is a object or instance of a base or extended class. Each entity have their own properties. The entity_get_info() is a function used for access entity information. Below is the sample code which show how to access the Entity information with entity ID.

Drupal : Loading revision of any Entity with example

In Drupal Node, User, Taxonomy, Files,.. are consider as entity. The combination of Entity type and Id is act as unique value. We can able to load each Entity as Object by using its unique id. For each update entity maintain a revision with an ID. Below is the example show how to load the revision information of a entity.

Drupal : Programatically update a Entity with Revision

In Drupal 7 and 8 we can able to update Entities values. By default it not creating revisions for update. To Ensure revision for or changes we need to add a "revision" parameter to the Object of Entity. Below is the syntax and example of programatically updating entity with revisions.codeexpertz

Drupal 7 : Programatically Loading and Updating Commerce products with Example

We using Drupal Commerce to store and retrieve line Items. It treat product as separate entity. The product informations are able to load by its product ID, the product information we get as Object. Using the product object we can update the values of commerce product. The below Syntax and example shows how to load commerce product and update values programatically.

Drupal 8 : How to use MERGE(INSERT+UPDATE) query with Syntax and Example

MERGE is the short hand Drupal database statement used to perform both INSERT and UPDATE functionality in same code. It Will check whether record is already exits with given condition, yes then update based on condition otherwise insert a new record. The merge() is a function of Drupal 8 core class used for MERGING record based on condition records. Below is syntax and example of how to use MERGE statements in Drupal 8.

Initial Table be like:

Related Blogs:

Drupal 8 : How to use DELETE query with Syntax and Example

Using the object of core Drupal class we can perform database queries. Delete is the data deletion query used to remove data from Database based on conditions. The delete() is a function of Drupal 8 core class used for remove records. Below is syntax and example of how to use DELETE query in Drupal 8.

Before Delete Table be like:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17
CE 003 Kumar 25

After Performing delete Query table records like:

Related Blogs:

Drupal 8 : How to use UPDATE query with Syntax and Example

UPDATE is the Data Manipulation Language(DML) query in Database management system. Using the object of core Drupal class we can perform database queries in Drupal 8. Update is the data modifying query used to change data in Database. The update() is a function of Drupal 8 core class used for update records. Below is syntax and example of how to use INSERT query in Drupal 8.

Before Update Record in Table be like:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17
CE 003 Kumar 25

 

Related Blogs:

Drupal 8 : How to use SELECT query with Syntax and Example

Using the object of core Drupal class we can perform database queries. Select is the data retrieval query that has been done with help of select() of Drupal 8 core class. Below sample show how to use select query in Drupal 8.

Output:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17
CE 003 Kumar 25

Related Blogs