Drupal provides a standard, vendor-agnostic abstraction layer for accessing database servers.

learn more… | top users | synonyms (9)

0
votes
1answer
13 views

How can I update the field of the entity?

I have an "Question" entity, and I need to updates its 'key' field (of string type): My code isn't working: $storage = \Drupal::entityManager()->getStorage('question'); $query = ...
0
votes
1answer
12 views

What are some specific reasons NOT to share a users database table between sites?

I'm building a site for a client, and surprise! Turns out they're using a shared users table between multiple Drupal 7 sites (completely different code bases, different config, etc). I'm only supposed ...
0
votes
1answer
22 views

Is it possible to detect access to table on site db table and redirect the db query to a db shared by multiple websites?

I'm working on a project where I use a database that is common to all sites and another that is specific to each. Is there a way to detect access to a specific table on a contrib module (maybe using a ...
-1
votes
2answers
25 views

Select fields from three tables using db_select()

SELECT u.`uid`,u.`name`,f.`field_user_first_name_value`,l.`field_user_last_name_value`,u.`mail` from users as u, field_data_field_user_first_name as f, field_data_field_user_last_name as l where ...
0
votes
1answer
12 views

Autcache + Varnish modules installed but cache tables growing

I have a site in Drupal 7, multilanguage and multidomain, and when I do a weekly manual database backup (apart from the automated ones), I see that the size of the mysqldump file is of about 200 Mb. ...
0
votes
0answers
10 views

Uncaught exception thrown in session handler

When logging into Drupal 7 website as admin, I'm getting the following error: UNCAUGHT EXCEPTION THROWN IN SESSION HANDLER. PDOException: SQLSTATE[HY000]: General error: 145 Table ...
0
votes
0answers
11 views

Using user_load() 500 error [on hold]

I have custom module and whenever I try to use the user_load function to load account information for a user, the _drupal_shutdown_function() is called with the callback "session_write_close". It ...
0
votes
1answer
14 views

Creating trigger function in Postgres

I was developing my own customized module in Drupal 7. Is there any way I can create at run-time a trigger function in PostgresSQL? A sample scenario is when after successfully deleting a record in a ...
0
votes
0answers
9 views

PDO exception when try delete statuses

I am getting pdo exception error when I am trying to delete a status update. There is a sub module in statuses module, Statuses Comments Flag Integration. May be it has some problem (In addition I am ...
0
votes
0answers
27 views

ISSUE ACQUIA DEV TOP DRUPAL ALREADY INSTALLED

Well after 3 days of headsmahsing against this issue and trying to resolve it by reading the documentation available, I think it’s time to expose my problem. ^^ Every time I try to create a new web ...
0
votes
3answers
39 views

Use db_select with multiple conditions of which one needs to apply

My question is not a duplicate and it has complex conditions. Please let me explain. In my second condition, first I need to check if number value is correct (in first condition I checked complete ...
-1
votes
1answer
21 views

How to run hook_update for the database

Suppose we have a simple module with 3 files: test.info, test. install and test.module. test.install <?php function test_schema() { $schema['test'] = array( //fields 'fields' ...
4
votes
2answers
227 views

How do I add a condition to a query?

$acl_ids = array(1,2,3); $database = \Drupal::database(); $result = $database ->query("SELECT {nid} FROM {acl_node} WHERE grant_update = :grant", ['grant' => 1,]) ...
0
votes
2answers
27 views

look up page View by its path

We can search all the default views on our relatively new Drupal 8 site, to see what view resides at a particular path, with a query like: $view_trim_path = 'blog'; $query = ...
0
votes
1answer
14 views

Problem with the schema structure produced by Schema module

I have a drupal 7.34 installation in my local computer. I also installed schema 7.x-1.2 module. Now Below is my code: function myid_schema(){ $schema = array(); $schema['myid_templates'] = ...
0
votes
1answer
26 views

Best way to store not publicly viewable data? [closed]

I wanted to know what is the most suited to store not publicly viewable data? Here is an example what I want to achieve: Imagine having a personal section about me. On this site I show the visitors ...
0
votes
2answers
29 views

How To Rescue Content from a Corrupt Database

I have spent many weeks inputting content into a commerce system. The database is corrupt. (The website displays fine for an anonymous user, but if you log in you get a blank page. Backups/restore all ...
0
votes
1answer
33 views

get menu link Page Settings from View configuration

When I have a node on the main menu, I can find its Menu Settings with an entityQuery on the content entity for its menu link, for example: $system_uri = "entity:node/42"; $query = ...
3
votes
1answer
25 views

Is it possible to create a calculation field using Drupal's database abstraction layer?

I am trying to work out if it is possible to write the following using Drupal's database abstraction layer. The tricky bit is the second field which is a function to calculate distance. Is it ...
0
votes
1answer
17 views

Dynamic Select Query On Another DB

Is there a straightforward solution to do the dynamic select statements against another database on the same server? I fooled around with attempting to modify the documentation example to no avail. ...
1
vote
1answer
31 views

Can I specify 'greater than' with db_delete()?

I am new to Drupal 8. I can use the following code to delete a record where salary == 45 $salary = 45; $num_deleted = db_delete('test_table') ->condition('salary', $salary) ->execute(); ...
1
vote
1answer
58 views

How do I use “GROUP BY”?

How do I use GROUP BY to display the result by group (email)? this is my file .php <?php /** * Created by PhpStorm. */ namespace Drupal\gestion_contact\Controller; use ...
0
votes
0answers
10 views

DATE_FORMAT function in where

I have following query which should return the bookings for particular day before specific date. $result = db_query("SELECT * FROM {dr_booking} k WHERE k.bdate >= :date AND k.mid = :mid AND ...
0
votes
2answers
18 views

How to get last insert ID of drupal_write_record

I need to get the last inserted id in drupal 7. I am using drupal_write_record('user_log', $log) How we can get the last_instered_id?
1
vote
1answer
25 views

EntityQuery condition “is not equal to…”

Problem : I need filtering entities based on the value of a multiple-choice field. I want my query returns all entities except those who have a given value ('doe' for this example). Actual : ...
0
votes
0answers
32 views

how to use a common external database for local site and live site without causing performance issues?

I have a site code and database on live server.I have the same code on local and I want to use that live db on local code.i have done that by changing settings php and it works.But it loads extremely ...
0
votes
0answers
28 views

Feeds SQL Import shows data in preview but fails to import

I have a problem on a client site with a Feeds import that shows the correct data within the import preview but does not copy the data across to the assigned field during the import. There are 18 ...
0
votes
0answers
10 views

How to control the fields states of Content Type?

I have several fields in my Content type entity and some of them should depend on the states of others. How can I implement it? Drupal 8 I tried the hook_form_alter () , but all elements, I add ...
0
votes
1answer
23 views

When a link is clicked, a value is retrieved from the table and displayed on a Webform field

I have created a basic page with two buttons, "Yes" and "No". When the "Yes" button is clicked, it is directed to the webform. Aim: When the webform appears, it displays a value from the table into a ...
0
votes
0answers
9 views

Display data on checkboxes when a webform loads

I have data from a table "customer" in this format: "data1,data2,data3," Examples: "tenant, training, consulting" "other" The key-value pairs are for the component of the webform are: ...
0
votes
1answer
55 views

How so I execute $query->orderBy('FIELD(node.nid, 5,12,3,6)', 'ASC')?

I am currently converting code from Drupal 7 to Drupal 8. So far I am unable to find resources on how to convert the call to orderBy() which uses an expression. $query->orderBy("FIELD(node.nid, ...
0
votes
2answers
19 views

hook_views_data join table on multiple columns

I have 3 tables lms_user, lms_answer_initial and lms_model_answer and need to join them to display a view on certain columns. I can successfully join the first 2 tables (lms_user, lms_answer_initial ...
0
votes
1answer
9 views

VotingApi function takes time to update the database

I have added a menu item that calls a function that calls votingapi_set_votes and delete votes. This function works locally fine but when uploaded to the hosting and when i call the function it takes ...
1
vote
1answer
22 views

Create a page with database data in a module

I am new to drupal and in a process of developing a custom module. My module will do a couple of things: (ADMIN) User will be able to select a zip file and upload it (ADMIN) The module will than ...
2
votes
1answer
21 views

What causes my problem when trying to create multiple tables in hook_schema?

I'm working on a module that has 2 tables and this is my code: function gen_schema(){ $schema = array(); //table cv $schema['cv'] = array( 'description' => 'table contenant les cv.', ...
0
votes
0answers
16 views

Understanding Relationship Between `file_managed` and `file_usage` tables

I am trying to understand the Drupal database schema because I need to access the database via MySQL by another system and I do not have access to the original Drupal developer of the site nor do I ...
2
votes
2answers
29 views

Understanding `file_usage` table

I am trying to understand the Drupal database schema because I need to access the database via MySQL by another system and I do not have access to the original Drupal developer of the site nor do I ...
1
vote
1answer
15 views

Understanding `file_managed` table

I am trying to understand the Drupal database schema because I need to access the database via MySQL by another system and I do not have access to the original Drupal developer of the site nor do I ...
0
votes
1answer
76 views

Cannot change an existing field's type. in field_update_field() line 240 of field.crud.inc

My instance of drupal is throwing an error. The file that is throwing the error is modules/field/field.crud.inc The error is FieldException: Cannot change an existing field's type. in ...
0
votes
1answer
18 views

Entity query - wrong nid

Hi i have following querry: $query = \Drupal::entityQuery('node')->condition('type','article'); $result = $query->execute(); Then i want to access all content: $nodes = ...
0
votes
1answer
34 views

Query - Content type [closed]

i want to get all created content of some content type by query. By now i can acces nodes by their ID. $MyNode = \Drupal\node\Entity\Node::load(1) I tried some query, but none of them worked for ...
1
vote
0answers
9 views

How can we configure the Master slave concept for moving field data to slave database?

How can we use drupal master slave setting to push field data into slave database and starts using field data from slave database? Is it even possible with drupal 7?
1
vote
1answer
19 views

SQLSTATE[42000]: Syntax error or access violation in drupal views query [closed]

When trying to preview a view containing references to three Field Collection module fields, I get the following error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in ...
5
votes
3answers
51 views

How can I programatically prevent users from saving the same entity twice in a row?

My server sometimes gets overloaded, and sometimes people press the "Save" button on an entity creation page several times, which results in multiple versions of the same entity being created. So, I ...
0
votes
1answer
14 views

Taxonomy term reference field from custom database table

I am trying to create a taxonomy term reference field or the equivalent in a View that uses the uuid of a field in a custom table. This field can contain multiple uuids. My first approach after ...
0
votes
1answer
25 views

Insert multiple checkbox value from webform into table

I created: a webform named Test Number checkboxes checkboxes named Number with values one, two and three using Form Builder a table named checkbox_check Aim: When the webform is submitted, the ...
0
votes
1answer
27 views

Retriving nodes by content type using Drupal::entityQuery

I created a content type named product. How can I retrive all node of such content type using the entityQuery method? I tried with this, but it doesn't works: $ids = \Drupal::entityQuery('product') ...
1
vote
0answers
26 views

Use webforms to search and edit information from a custom table on the database

I am attempting to search and edit information by using 2 webforms. The custom table is found in the database that my Drupal project is using and is named "test_update." It has 2 records on the table. ...
0
votes
1answer
23 views

Using xdebug to find out why a variable is mysteriously set to 0

Thanks in advance for your help! I'm new to xdebug and trying to figure it out. I have a situation I'm trying to debug where a variable is mysteriously set to 0. I know from xdebug (I'm using ...
3
votes
2answers
91 views

What code should I use where I used db_query()?

I want to execute SHOW TABLES in Drupal 8. In Drupal 7, I would use db_query("SHOW TABLES"), which is deprecated in Drupal 8. What should I use for Drupal 8?