Questions tagged [database]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
32 views

When old field revisions should be deleted from the database?

I have a question about old fields revisions in Drupal 8. For example I have "Full Title" field in different paragraphs. I have deleted this field from one of the paragraphs, for example ...
-3
votes
0answers
26 views

How to access array element? [closed]

I have the following array: Array ( [1] => Drupal\node\Entity\Node Object ( [in_preview] => [values:protected] => Array ( [nid] => Array ( [x-default] => 1 ) [vid] => Array ( [x-...
0
votes
3answers
35 views

Use read-only database user to minimize security risks

I want to phase out an old, unmaintained Drupal 6 page. The website should still stay online, but should be read-only. I want to change the database user so that it only has read privileges. I don't ...
-3
votes
0answers
24 views

users randomly being created when clearing all error messages on user registration which also causes EntityStorageException

This error came up because I was trying to fix an issue related to user registration. Right now I have an issue with users creating their account. Users create their account by filling out the user ...
0
votes
0answers
39 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::...
0
votes
0answers
16 views

How to capture the SQL on database errors

Is there a way to capture the SQL that was submitted to the database when the database throws an error?
0
votes
0answers
13 views

LOAD DATA LOCAL INFILE suddenly stop working [duplicate]

I have created a script that insert record from csv to data but it suddenly stop working on and I am getting error : General error: 2 File '/code/sites/default/files/data_file/CSVFile.csv' not found (...
0
votes
0answers
16 views

Dump raw select query with parameters values

I would like to debug select query and I use the next code, for example: $connection = \Drupal::service('database'); $query = $connection->select('node', 'node'); $query->fields('node', ['nid']) ...
6
votes
1answer
89 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(...
1
vote
1answer
37 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 ...
1
vote
1answer
26 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 ...
1
vote
1answer
33 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 ...
0
votes
1answer
21 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('...
0
votes
0answers
46 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 ...
1
vote
0answers
23 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 ...
0
votes
2answers
35 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 ...
0
votes
2answers
97 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 ...
1
vote
1answer
33 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 ...
0
votes
0answers
35 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 ...
0
votes
0answers
71 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 ...
1
vote
1answer
39 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($...
3
votes
0answers
35 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 ...
0
votes
0answers
55 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 ...
0
votes
1answer
30 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 ...
1
vote
1answer
23 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 ...
1
vote
0answers
31 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 ...
1
vote
1answer
33 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 ...
0
votes
0answers
27 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 ...
0
votes
0answers
19 views

hook_update_N column addition - error

I am adding 2 columns to an existing table using hook_update_N function as below: function cca_update_8904(&$sandbox){ $connection = \Drupal::database(); $schema = $connection->schema(...
2
votes
2answers
105 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....
1
vote
1answer
116 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 ...
4
votes
1answer
70 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 ...
0
votes
1answer
71 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 ...
1
vote
2answers
82 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 ...
1
vote
2answers
48 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', '...
1
vote
2answers
313 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/...
0
votes
2answers
74 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 ...
-6
votes
2answers
69 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 ...
0
votes
1answer
53 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 ...
0
votes
0answers
52 views

How to install drupal 9 with PostgreSQL using Docksal?

I use docksal for developing on Drupal. Recently I decided to install Drupal 9 with PostgreSQL as a database using Docksal. Firstly, I cloned this git-repository. https://github.com/docksal/...
0
votes
1answer
31 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 ...
0
votes
0answers
40 views

Override core files database, statement, connection

I'm trying to turns things in everyway in order to override those core files: Database, Statement & Connection in order to build a simple array of SQLQueries along with their results in order to ...
1
vote
0answers
37 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 ...
0
votes
0answers
42 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 ...
0
votes
0answers
36 views

how to download media into drupal 9 database from a sql database

here my problem i have old blog made in laravel and my boss want me to migrate all the article to a drupal website so i create a plugin that migrate the article title and text but i have to download ...
0
votes
0answers
10 views

How do I restore/recreate accounts created using OpenID after restoring from a backup?

After performing a rollback of our Drupal 7 site, we realized we had 20 - 30 users that were "lost". Looking for the most efficient / possible (?) way to recreate those users with the least ...
1
vote
0answers
132 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 ...
0
votes
0answers
14 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 ...
0
votes
0answers
27 views

migration plugin works but fail to migrate in drupal database

I try to migrate old blog article to a drupal website here is my migration class : class Article extends SqlBase { /** *{@inheritDoc} */ public function query() { $query = $this->...
0
votes
0answers
100 views

Why my Migration don't reckognize my plugin in drupal 9

I'm new in drupal and I try to migrate the article of an old blog with sql database to my drupal 9 project. I follow the instruction give by the drupal API migration docs, so i connect the 2 database ...

1
2 3 4 5
61