Drupal

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

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

Insert 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. Insert is the data saving query used to store data to Database. The insert() is a function of Drupal 8 core class used for insert records. Below is syntax and example of how to use INSERT query in Drupal 8.

Before Insert Table be like:

EMPLOYEE_ID EMPLOYEE_NAME EMPLOYEE_AGE
CE 001 Mohan 20
CE 002 Dinesh 17

 

After Performing Insert Query table records like:

Related Posts:

Drupal 7 : Accessing User Profile fields and changing programmatically with example

In Drupal 7 Profile2 module help to create user profiles. The Profile2 module handle each profiles as separate entity with set of Drupal fields. Similar to changing user account we can change profile values. Below example show how to access profile values and updating profile values.

Drupal 7 : Select list options by Taxonomy term depth(Parent Child) with source code

In Drupal by Taxonomy term list are arranged as parent child format. Similarly we can able to create List option in our custom form. Below is the source code to generate option array as Parent child hierarchy. List key is Term ID and display name is Taxonomy term hierarchy.

Drupal 7 : Creating custom hook for user defined functions with sample code

In Drupal HOOK are used to alter values or construct values to program. It similar to implementing class in Object Oriented Concepts. In Core and Contributed modules create their HOOK functions for extending functionality. In custom module we can able to create our custom HOOK to alter data from other modules.This is achieved by using the function drupal_alter().

Drupal 7 : Programmatically adding Fields in View with Example

By Default Drupal Views show the fields that are configured in UI. Based on our requirements we can able to add custom fields to view on rendering. This feature is achieved by using the HOOK hook_views_pre_view(). Using the object of $view we can call function “add_item()” this will add the fields to the View.

Drupal 8 : Programmatically create File in server with sample code

In Drupal 8 we can able to programmatically create files in sites file system. By using function “file_save_data()” from Files module from core. This function accepts parameter of file content with optional parameter as destination and replacement type.

Drupal 7 : Programmatically render view(views_get_view()) with Exposed filters - Samplecode

In Drupal 7 we render view by calling the function views_get_view(), this function render returns view results. Normally we filter view result by specifying filters in view or exposed filters. For programmatically rendering view we need specify the exposed filter value in object of view.

Drupal 7 : ApacheSolr custom search using Keyword - Example

ApacheSolr is the effective method to search the our site contents. With help of ApacheSolr module we can able to index site contents in apache solr server. To get solr server content from using function “apachesolr_search_execute”. This function return searched results as array.

Drupal 7 : Check given Path is valid system path or not with source code

To check given path is Drupal system path or not by using below functions. It check all Drupal system and modules path. It accepts string of path is argument return TRUE if valid path else FALSE if non exist path. We can able to pass wild cards for dynamic paths. For example node/*, comment/*. This function will check these type of paths also.