Questions tagged [database]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
185 views

update a entity with presave method to avoir a loop

In the hook_entity_update function update_candidat_from_contrat_direct(Drupal\Core\Entity\EntityInterface $entity) I call another function in which : I create a new node $new_entity = \Drupal::...
cocq's user avatar
  • 45
11 votes
1 answer
1k views

What is the significance of dumping the tablespaces?

While recently running drush sql-dump on a server where there were never any error messages, I have started to get: mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(...
siliconmeadow's user avatar
1 vote
1 answer
154 views

Is there a database lock mechanism?

I have a parent child entity relationship which is driven by a REST API. The payload contains data for both the parent and the child. The parent can have many children. When the (child) payload is ...
liquidcms's user avatar
  • 1,248
2 votes
1 answer
468 views

Check if the connection to the database is available

I have 2 databases, the first one with Drupal and the second one with external data. In a controller I want to read data from that second database and display it. As the external database can be ...
Javier Rey's user avatar
1 vote
2 answers
900 views

Limit size of cachetags table

One of the site has fairly large cachetags table at over 418K records. Is there a way to limit the size of this table. This table is not cleared on cache clear. Since Drupal 8.4 there has been a way ...
amit's user avatar
  • 444
0 votes
1 answer
262 views

Dynamic query with left join

I need to collect comments that belong to certain user and submitted on pages of certain content type nodes. Currently I'm making two queries: $nodes = db_select('node', 'n') ->fields('...
user102362's user avatar
0 votes
0 answers
446 views

Failed to update database after upgrading to 8.9.13

I'm new to drupal and was recently tasked with upgrading the drupal core version of one of our sites. I upgraded from 8.3 to 8.9.13 and everything went smooth enough until it came time to update the ...
IeuanByers's user avatar
1 vote
0 answers
35 views

Double Publish is Required To Update Data When Node is Under High Traffic

We have a high-volume production site that is running into issues of serving stale data when a node is republished. Description/Example Of Issue I go into a node, create a new draft, then make some ...
sorebear's user avatar
-1 votes
2 answers
2k views

How do I join two tables?

I was following this tutorial on Drupal module development. It talks about database query joins in module development. The tutorial is made for Drupal 8 and I'm using Drupal 9. Then I made this (look ...
Natanael Osorio's user avatar
0 votes
2 answers
788 views

Converting a Views SQL query with INNER JOIN to an EntityQuery

I'm trying to create a custom JSON:API resource that returns the entities that have been flagged by a user. (The Flag module does not offer a way to get this out of the box.) I used Views to build a ...
Patrick Kenny's user avatar
1 vote
1 answer
460 views

Unable to get titles to show up as higher priority in search than content

I have a website I am working on that has a TON of content. The client has noticed that when searching for titles in the site search, it seems to prioritize the body content over the title. So I ...
Patrick's user avatar
  • 1,310
0 votes
0 answers
165 views

How to migrate PDF files to specific node

I have a directory with PDF files and I have 45 nodes of content type Download. I have to migrate each PDF file to specific node. All PDF file names I read from a CSV. Before these PDF files, I had to ...
ckojo's user avatar
  • 1
0 votes
0 answers
2k views

PDO database connection error?

Super strange, my site was up and working fine yesterday. Today, I navigate to my home page and I'm thrown this series of errors: Warning: PDO::__construct(): php_network_getaddresses: getaddrinfo ...
Brittany's user avatar
  • 241
1 vote
1 answer
127 views

EntityQuery PHP issue when assigning the query to a variable

I am very confused about this behavior of EntityQuery, or maybe I am just missing something basic about PHP. Here is the query I am working with: $entity_query_points1 = \Drupal::entityQuery($...
Patrick Kenny's user avatar
3 votes
0 answers
42 views

Speed up login after changing user name datastore type to VARBINARY from VARCHAR

We have a project underway that requires the import of ~6 million users into Drupal (Core 7x) that have many (150K+) case-insensitive duplicate usernames. Importing these users with existing case and ...
CMSW's user avatar
  • 31
0 votes
0 answers
358 views

Unbuffered query errors and conflict in access to the database

I've been developing on Drupal at work for some time, now I also have a hosted personal site (on fastcomet). The first install was with 8.6 and php 7.2, then it has been idle for a while, now I ...
Francesco Marchetti-Stasi's user avatar
0 votes
2 answers
778 views

fetchAll Database query returns an error

I'm building a REST Resource in drupal 8 php that returns the result of a query to the database. However using the fetchAssoc() only returns one result. So I figured that fetchAll() returns all ...
mak212's user avatar
  • 3
1 vote
1 answer
497 views

How do I get the number of rows affected from an update query?

I'm having trouble figuring out how to get the number of affected rows from an update query in Drupal. I have a form where users can update their profile details. Now, not every user is going to ...
Julio Sandoval's user avatar
1 vote
0 answers
93 views

Database password revealed in PHP error_log?

Noticed some errors while updating to Drupal 8.9.11. As I'm reviewing I come across the following. Replaced the actual password with PASSWORD below. Is this intentional or a bug? I can't see why the ...
Jeff's user avatar
  • 93
2 votes
1 answer
50 views

List all node titles to better iterate on a list of names

I have a content type called Country and I have to verify what countries already exists in db and save the missing ones, comparing to a variable with all countries ($country_list). I am having trouble ...
Fabíola's user avatar
0 votes
0 answers
140 views

How to display or make the cities selectable in address module?

I'd like to set for users on Drupal 9-Website on the registration form and for some content-types a new field "Address". I did activate module "address" and added new field to user ...
lexx's user avatar
  • 21
3 votes
2 answers
2k views

How can I query by node title?

In Drupal 7 I had this code to query node fields and its respective title: $query = db_select('node', 'n'); $query->join('field_data_field_internal_institute_paper_i', 'iipi', 'n.nid = iipi....
supersize's user avatar
  • 263
1 vote
1 answer
891 views

How to update Drupal custom module after changing .install file

I am working on a pre-created Drupal 8 project that has a custom module called CCA(named out of project title). I have done the below update in the .install file to add a new column to the backend via ...
Rick's user avatar
  • 125
5 votes
1 answer
292 views

Force a single value base field to be in a separate table?

I have a custom entity type (eg: myentitytype), and I would like to add a new base field to it via hook_entity_base_field_info(). As I understand it, single value fields (with a cardinality of 1) will ...
m.stenta's user avatar
  • 743
0 votes
1 answer
635 views

Why isn't a PDO driver detected on the install page?

I have an old Drupal 7 project and I need to set it up on my localhost. I have Ubuntu 16.04, Apache 2, php 7.0, and MySQL 5.7 installed. Everything is working fine for other PHP scripts, But when I ...
Iqbal's user avatar
  • 191
1 vote
2 answers
417 views

How to run custom sql commands to database programatically

I'm using MariaDB as database backend and I would like to use built in "Sequences" to get an integer number generator. I need to dinamically create sequences and get their values. Following ...
briast's user avatar
  • 632
1 vote
2 answers
470 views

How to make a case sensitive entity query?

My custom entity type comes with a string field for which I would prefer case sensitive queries. When I use $query = \Drupal::entityQuery('my_entity_type') ->condition('my_token_field', '...
Tobias Krause's user avatar
4 votes
2 answers
3k views

LogicException: The database connection is not serializable - when I try to open any "gear" on checkout flow page?

So I'm on Commerce -> Configuration -> Orders -> Checkout flows. I'm editing a flow (it's the same with any of them), so i.e. I'm at page: /admin/commerce/config/checkout-flows/manage/...
MilanG's user avatar
  • 509
0 votes
2 answers
496 views

How do I edit serialized values in "config" and "key_value" tables?

While trying to switch original language of a Commerce product type I've encountered longblob serialized data in config and key_value database tables. Is there a quick way to edit them, possibly ...
int_ua's user avatar
  • 271
-6 votes
2 answers
493 views

Is it possible to import an SQL file? [closed]

I have an SQL database created from another application and I would like to add it to my existing Drupal 8 site. I didn't find a way to do so. I came across the Data module, but I have no idea how to ...
esQmo_'s user avatar
  • 107
0 votes
1 answer
1k views

How should I get data from the node table?

I am creating a Drupal Dashboard (PHP 7.2, Drupal 8.9). I'm trying to query the node table using the following code. $database = \Drupal::database(); $query = $database->query("SELECT ...
Harshit's user avatar
  • 103
1 vote
1 answer
358 views

How do I install with PostgreSQL using Docksal? [closed]

I use Docksal for developing on Drupal. Recently, I decided to install Drupal 9 with PostgreSQL as a database using Docksal. Firstly, I cloned https://github.com/docksal/boilerplate-drupal9. Then, I ...
Yakimkin Roman's user avatar
0 votes
1 answer
159 views

Extracting user field values from dynamic SQL queries

Aim I have successfully written a fairly long dynamic sql query, however am struggling with a seemingly simple part at the end. Although, I am able to successfully extract mail and name from the users ...
Darcy's user avatar
  • 145
2 votes
0 answers
161 views

Database dump without revisions?

Are there methods to exclude revision data in a database dump? The purpose would be to reduce the file size for developers that want a db dump for local development. I know that drush sql-dump has an ...
donquixote's user avatar
  • 3,632
0 votes
0 answers
54 views

Rollbacking from Yaml based configuration to database based configuration

We recently changed the way we deploy our Drupal site on our testing environment to a docker image. The issue is that we were using a file based configuration. The current applied configuration is not ...
Gabriel's user avatar
1 vote
0 answers
1k views

Is it safe to truncate the key_value_expire table?

I am seeing over 8 GB in the database for the key_value_expire table. Is it safe to manually truncate that table? This appears to be caused by a bug in the Honeypot Module, which I am unable to ...
user51769's user avatar
0 votes
0 answers
16 views

How to update value of single field of same node using node_save?

The problem statement: I have one content type called 'Employee' which has 10 nodes. I have to perform the voting for each node. I am saving the vote count in the field called 'vote count'. But when ...
Rohan1990's user avatar
0 votes
1 answer
141 views

where in database is renamed login for 'Rename Admin Paths"

A little embarrassing - I've lost/forgotten the login page for a Drupal 8.9 website. It was renamed using the module "Rename Admin Paths." I've gone to the module page at drupal.org and ...
turpentyne's user avatar
0 votes
1 answer
1k views

How do I create a table when a module is installed?

I want to add a custom table when a module I develop is installed. The code I am using doesn't seem to work, as the post table isn't created. What is wrong with the code I am using? /** * Installs ...
David montera's user avatar
0 votes
0 answers
23 views

Incorrect field of a content type in its display after migrating from a backup

The following two screen shots should explain the issue well: Here I have a content type Poll, where the first field is Question with machine name title. However, in Managage Display tab, the second ...
SaidbakR's user avatar
  • 430
0 votes
0 answers
23 views

EntityQuery get contents which were not modified [duplicate]

I'm writing a very basic query to get the count of contents which were not modified. The logic I'm applying here is simple too, just check if created = changed The SQL query is pretty straightforward ...
NKP's user avatar
  • 137
0 votes
1 answer
2k views

Error: "module does not exist" after I removed a module from the file system without disabling and uninstalling it

I removed a module from the file system without disabling and uninstalling it. And now I have error: Drupal\Core\Extension\Exception\UnknownExtensionException: The module drupalweather does not exist. ...
nathan111777's user avatar
2 votes
1 answer
1k views

How to make loadByProperties or entityQuery case sensitive for field value

Neither loadByProperties or entityQuery are case sensitive. How to make it case sensitive? I'm using MySQL as a database but would rather have a portable solution if possible. With LoadByProperty $...
gagarine's user avatar
  • 682
0 votes
1 answer
263 views

Why cannot I choose MySQL as database type in the installation page?

I downloaded the Drupal archive and extracted it on the dedicated server. In cPanel, I created a MySQL database, but when I try to install Drupal, in the Database configuration page, I can only choose ...
nathan111777's user avatar
-1 votes
1 answer
834 views

Ordering in a query gives "call to an undefined function"

I am using Drupal 8 and I am trying to order my query like so: $query = db_query("SELECT * FROM `heritage_source_info`WHERE text_id = :textid AND format = :format ORDER BY type ASC", [':textid' =>...
Saptaparnee's user avatar
1 vote
2 answers
313 views

How to get fetchField using db_query?

I wrote db_query in two ways, I followed the drupal documentation to write safe db_query, one of them doesn't work, I want to know what I'm doing wrong in the code below. // Worked perfectly function ...
sam's user avatar
  • 15
0 votes
0 answers
179 views

Database Rollback Transaction?

I have a multi database site, when I save my content type it is added in both the Laravel side database and the default Drupal database. Now most of my code is in try catch and it does not save data ...
Usman Manzoor's user avatar
0 votes
2 answers
3k views

How can I retrieve a user name and password?

Someone installed the drupal 8 site and did not share the password. I do not know what email he has used to install the site either. I do not have the password. In phpmyadmin, I clicked the database ...
GreenTree's user avatar
0 votes
0 answers
46 views

I have large gaps in NIDs on my site. Should I clean it up?

So, since I have a little extra time on my hands I’m doing some delayed maintenance on my personal site. You know, removing modules I don’t need anymore, cleaning up taxonomy, etc, etc. There is ...
Sean Reiser's user avatar
0 votes
1 answer
232 views

query condition comparing two fields

i am having this query : $db = \Drupal::database(); $exist_query= $db->select('user__roles', 'ur'); $exist_query->fields('ur', ['entity_id']); $exist_query->condition('ur.entity_id'...
Matoeil's user avatar
  • 3,389

1 2
3
4 5
63