Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

1
vote
1answer
29 views

For a customer database table, do I have other options, beside creating a custom module?

I'm upgrading my site to Drupal 8. Currently, I have a custom module with a custom database table and I query that to provide historical data that is in the table. The data is really purely tabular ...
0
votes
0answers
21 views

How to change the collation of an existing MySQL database? [on hold]

How to change the collation of an existing MySQL database ? This is a Drupal 8 site Currently my database is with collation utf8_general_ci Is it possible to convert an existing database with ...
0
votes
0answers
26 views

Creating a column in mysql to store uuid

In Microsoft SQL we have UNIQUEIDENTIFIER type while creating table and when inserted it fills auto-generated string into that row. Is there any equivalent type in Drupal 8 or should I use some ...
0
votes
1answer
22 views

entityQuery with multivalue date field

Is there way to use entityQuery in order to select nodes with multiple value date field. For example we have a content type event with a field field_event_date which may contain unlimited number of ...
0
votes
2answers
31 views

Select data from database

For the filter block I need to get the data from database. I have three tables "node", "node__filed_country" and "taxonomy_index". So I need to pull only those taxonomies which are realted to the ...
0
votes
0answers
24 views

Very slow menu_tree_check_access query - how to debug

I have a Drupal System which is running fine in production and locally but the dev/cons Db seems to have a problem. After looking a bit deeper into it I found that menu_tree_check_access takes 3.8 Sec ...
-2
votes
1answer
16 views

EntityQuery or UI views

I found answer a this question for Drupal 7 but not too much for Drupal 8. In general I found that views are easier way to query data. I am wondering more to performance, Are views faster? Can I ...
0
votes
0answers
9 views

Should I even bother using OPTIMIZE TABLE on my cache and watchdog tables?

Been ignoring my OPTIMIZE TABLE warnings for about a week now, as the project I'm building is still in dev and not much has used the db yet. Today I finally went into MySQL Workbench and ran the ...
0
votes
1answer
18 views

Use created year as condition in Entity Query

I'm performing an entity query that searches for nodes of my custom content type called 'news'. I want to perform the query in a way that only produces the 'news' nodes that have a Authored Date that ...
0
votes
0answers
11 views

How do I use addExpression() with a where/having clause?

I need to use the uses field in a having clause. Googling, I found it should work, but I get an error about uses being a not existing field. I tried replacing uses with count(*), but I get the same ...
0
votes
0answers
26 views

EFQ with huge data

I'm using EFQ to load nodes. However when the data is huge the page naturally breaks. Is there a way to lazy load the EFQ result or any idea how to optimize it? Noting that the client doesn't want ...
0
votes
2answers
34 views

Help with database query

How can I convert this sql query into a Drupal 8 query? I need all nodes of type 'page' that has not been referenced by nodes of type 'article'. Article content type contains an entity reference ...
0
votes
0answers
19 views

Method addWhereExpression does not consider fields without values

Tell me how to create the correct query. In its own handler filter for views, a $this->query->addWhereExpression query is created, where the fields in the nodes are selected. If all the fields are ...
0
votes
1answer
11 views

Entityreference not saved correctly inside ContentEntityForm

I was having a weird bug with my views. Some entity-references from my main-entity didn't show up in my view. I investigated further with entityQuery and came across some weird action. I can get the ...
0
votes
0answers
24 views

how to get all orders filtered by one product using EntityFieldQuery?

The below code will filter by date but what i really need is to filter by product. $query_invoice = new EntityFieldQuery(); $query_invoice->entityCondition('entity_type', 'commerce_order') ...
0
votes
0answers
20 views

EntityFieldQuery and use the statistics module

How to get 10 entities with the best number of views per day (daycount from statistics module) with EntityFieldQuery? My code that displays the entity, but how to get the best views? function ...
-1
votes
1answer
22 views

js in default/files causes extreme slowdown of website [closed]

for the past week my website is plagued with over 4000ms hanging upon entering, more so at sometimes. After using firefox's performance monitor, I pinpointed it to several lines of code in a js file ...
1
vote
1answer
167 views

Site not working after the database update

I cloned a repo of a site to my local computer, imported the database and ran "Composer install --with-dependencies" after the installation had been done I entered the local site and it worked, then I ...
0
votes
0answers
16 views

problem with db_select, ->condition dont work if compare a field with a value

im trying to make a field with the results of a sql in php . im trying to make a condition with the field "manifestacionType" and compare with value 'compuesta'. The problem is that i dont know to do ...
0
votes
1answer
53 views

Views relationship to second database

Is there any possibility to add a relationship in views from a second database to the default one. I.e. I am using a second database which contains one table with a userid. In my hook_views_data I ...
0
votes
2answers
55 views

How to create a table in second database with hook_schema

I want to use two databases, that works following: How can I setup multiple database connections in Drupal 8? . I can set the connection in the settings.php file, access it by injecting a different ...
1
vote
1answer
19 views

query to retrieve all translations and nodes of a language that has been removed from the system?

I am experiencing an issue after a language has been removed from the system. Every time I go on the admin/content page on a drupal 8 site I get: Error: Call to a member function getId() on null ...
2
votes
1answer
31 views

Using Mysql LOAD DATA LOCAL INFILE with drush

I want to able to load a huge CSV file directly into the database using LOAD DATA LOCAL INFILE like below: LOAD DATA LOCAL INFILE 'Subscriber.csv' INTO TABLE temp_data FIELDS TERMINATED BY ',' ...
0
votes
1answer
22 views

Extract data from Field Collection using db_select()

I'd like to use db_select() to extract values from a field collection attached to the user profile, to help speed up some complex Ajax forms (rather than loading the entire field collection, using ...
0
votes
1answer
15 views

db_insert a lot of records

I am struggling to sort out how to insert a lot of records using db_insert Please see below for the code. I can't have a for loop in the array. It breaks but I am dealing with looping through a lot ...
0
votes
0answers
36 views

How to sort $nodes after executing an EntityFieldQuery [duplicate]

Am using Drupal 7 and EFQs. After executing the query and geting all the nodes listed in a custom module, I need to sort them on node title field. I can use usort and other php functions but my ...
0
votes
3answers
63 views

How to use same database for two website but different panel?

Is this possible to use same database for two different domain? Example domain1.com and domain2.com but their views and designing are different for both site but content will be same . If I change in ...
0
votes
0answers
11 views

Show results from one field first in aggregate facet field

I have items with two fields primary color and secondary color. And an aggregate field containing both field. I want to show results from facet of aggregate field such that if item match from primary ...
1
vote
1answer
39 views

Increasing performance of cache_form on high traffic sites

I am noticing a significant performance increase in my load testing when this table is small, but due to a large traffic site this is growing very quickly. I have read that it is not a good idea to ...
1
vote
1answer
27 views

Where are entities stored in MySQL by default?

Drupal 8 has a powerful entity API that manages all the content of the entities. How can these entities be accessed outside of Drupal? Which are the tables and what is the format?
0
votes
2answers
39 views

How to update custom content type fields value in bulk?

Is their any way to provide the bulk edit in the custom content type fields values by csv or in bulk.?
1
vote
2answers
25 views

Change account settings in db

All sites on our server is currently getting spam users registering for new accounts. Since none of the sites needs the option available for user to sign up, we would like to change the account ...
0
votes
1answer
28 views

Problem with database migrating Drupal 8 site from local to web host (multiple databases)

I'm trying to migrate over a Drupal 8 site developed on my local PC to the web host. Everything is fine with the files transferred over (/site/files, /modules, /themes, etc.), the database has been ...
0
votes
1answer
20 views

Migrating sha1 user passwords into drupal 7

I have an old zend 1.8 cms site and I wish to import users into a drupal 7 site so that a user can login with their sha1 password without having to changing it. Once verified convert the submitted ...
0
votes
1answer
26 views

EntityQuery how to get all delta and good for field_dates

I've got these dates linked to a node. I just want to make a request to render all node when time() is between field_date_value AND field_date_end_value OR time() is < to field_date_value (ps: ...
0
votes
0answers
32 views

Does drupal cache the settings?

I've been given a Drupal site to put on our server, I've not worked with Drupal before. From my understanding, the database credentials are stored in the settings.php file: $databases = array ( '...
0
votes
0answers
32 views

Adding a 'OR' condition to query

I need to add a OR condition to my query so that I can get all nodes related to a particular term. Here is what I have done : $query = \Drupal::database()->select('taxonomy_index', 'ti'); $query-&...
0
votes
1answer
29 views

Get relationships between tables when no foreign keys are present

How can tell the relationships between tables when no FKs are being used? Just started working on a (partial) data export from Drupal MySQL database with ~1000 tables that contains hardly any foreign ...
0
votes
3answers
104 views

Not able to connect to remote database after migration

I am moving a running site from staging to production. The production environment has 2 servers, one for frontend and the other for the database. The issue is when I try to browse the website, I get ...
0
votes
0answers
11 views

How to replace the db_placeholders() function

I am upgrading a Drupal 6 site to Drupal 7. There is a custom module in this site and in one of the .module files they used a db_placeholders() function in a DB INNER JOIN query. As Drupal 7 has ...
0
votes
1answer
30 views

How to import content to Drupal 8 site by inserting it directly in the database?

As I was not able to find any working way of importing content from csv, I decided to export it to .csv from the old site (database) and import it then into the Drupal 8 database. However, after I ...
0
votes
0answers
54 views

How to come up with SELECT queries?

I have a query like this: SELECT DISTINCT field_name FROM table_name I tried: \Drupal::database()->select('table_name', 't'); $query->fields('t', ['field_name']); $result = $query->...
0
votes
0answers
11 views

DATABASE SQLSTATE SQLSTATE[HY000] [duplicate]

Today we tried to check our website but we found this error. I don't know what happened exactly. PDOException: SQLSTATE[HY000] [2002] No such file or directory in Drupal\Component\DependencyInjection\...
0
votes
0answers
21 views

How to synchronize the database upon team work on Drupal 8 project? [duplicate]

For example, there is being written a big project on Drupal 8 by several developers. They use Git for team working. The first developer is creating some node types and adding some test nodes. At the ...
0
votes
0answers
10 views

D7: Race condition(?) when deleting a node with lots of associated nodes?

I've got a situation where I have a content type -- let's call it "book" -- which has a number of related nodes attached to it -- let's call them "chapters". A user's home page shows snippets of each ...
0
votes
0answers
22 views

Method for nested array and count()

Is there a way in Drupal 8 Views to do this query without having to write a module or completely custom query outside of views? SELECT Entity_id FROM node__fieldname WHERE (field_one, field_two) ...
0
votes
0answers
33 views

Entity query - using parent/grandparent ids as a condition

I have relationships linking a node to a child paragraph, with a grandchild paragraph: Node |_ paragraph child |_ paragraph grandchild Using an entityQuery, I can get child items using ...
0
votes
1answer
25 views

Use mysql SET variables in db_query

How can I use mysql SET variables while using my PDO queries? db_query('SET @x := 5,SET @y := 6, SELECT * from mytable')->fetchAll(); I have tried this and many variations of this statement with ...
0
votes
2answers
70 views

Drush 9 - Destination Argument Does Not Exist

I've been struggling a lot with Drush 9 sql:sync the past few months. I've gotten it to work a few times, but I've been stumped by this most recent problem: $ drush sql:sync @prodv2 @local --debug ...
0
votes
0answers
23 views

Query not returning all rows (Tablesort/Pager)

I have a problem with my query, this one not returning all rows from my database $query = $db->select('projection.ecriture', 'ecr'); $query->fields('ecr', array('date', 'datedelecheance', '...