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
28 views

How to establish a database connection to Microsoft SQL server that has more than one server instance?

For an MSSQL database at the IP 192.168.55.55 and a server name of MYDB2, what should my database settings be in the settings.php file? (Please note, the machine has more than one database server, so ...
arnoldbird's user avatar
  • 1,173
0 votes
1 answer
95 views

Update database issue

In 2 of my 3 Drupal websites, drush updb crashes with the following error after upgrading from Drupal 9.5.11 to Drupal 10.2.2. In BatchStorage.php line 143: [Exception] Serialization of 'Closure' ...
Pierre Ernould's user avatar
0 votes
1 answer
32 views

REGEX_REPLACE error when running DB query from update hook

This MySQL statement runs fine on MySQL 8.0.33-0ubuntu0.20.04.2: mysql> UPDATE node__body SET body_value = REGEXP_REPLACE(body_value, "<img.*base64.*>", ""); Query OK, 0 ...
pmagunia's user avatar
  • 697
0 votes
1 answer
90 views

How to let users write private letters to me about a node?

I want to let users the ability to write personal letters to me based on nodes they read while letters are stored in the Drupal database itself (no emails involved) and will include these fields: ...
alesios's user avatar
0 votes
0 answers
21 views

Kernel and functional testing with an MSSQL database

I am new to testing custom modules. My custom modules create and update custom nodes. From my reading, I need to use Kernel or Functional tests to test these operations. My Drupal 9 installation is ...
spacecraft96's user avatar
0 votes
2 answers
35 views

How can I get the record of the last insert?

Is there a method to be called that will get the ID of the record just inserted? In my module the first thing done is the insert of some data into a table. After that I have other things to do in the ...
Cy Jobes's user avatar
1 vote
0 answers
66 views

PDOStatement::execute(): SSL: Broken pipe [closed]

I have a Drupal 9.5.11 site running well on a single EC2 instance and a remote MySQL server (RDS). I am trying to replicate a very similar scenario with a single EC2 instance but I am using AWS ...
Josh's user avatar
  • 195
0 votes
0 answers
34 views

Unable to add Menu Items due to IntegrityConstraintViolationException

Background I recently encountered an error when I try to create a new menu item: Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default ...
GeorgeCiesinski's user avatar
0 votes
1 answer
98 views

How to join the node table with the url_alias table in a dynamic query?

Joining the node table to the url_alias table requires CONCAT. Here is an example of how this can be done: $results = $db->query(" SELECT n.nid, n.title, a.source, a.alias FROM ...
arnoldbird's user avatar
  • 1,173
0 votes
1 answer
32 views

How do I sort view results by query order?

In my twig I use {{ drupal_view('slider', 'block_1', '74,84,82' ) }}, how can I make sure the output of this view has the slides in that specific order? Currently on D9. I've looked around but can't ...
Lenny's user avatar
  • 214
3 votes
1 answer
80 views

Drupal::entityQuery add CASE to have NULL values displayed last

I want to sort some entities in ascending expiration date, but I want those without expiration date to be at the end. Is there a way to add a CASE expression like this to the Drupal::entityQuery? $...
user7167081's user avatar
1 vote
2 answers
97 views

Finding all nodes not referenced by a menu

I see this question was asked for Drupal 7, but the menu_link table doesn't exist in Drupal 9. Is there a SQL query for listing all nodes that are not assigned to a menu?
C0c0b33f's user avatar
0 votes
1 answer
322 views

Multiple primary key defined When importing DB to Dev

I'm trying to update my D9 dev site database using my production database, but it keeps erroring out when it reaches to ALTER table section in the database. This is the ERROR 1068 (42000) at line ...
MetalBearSolid's user avatar
0 votes
0 answers
51 views

How do I switch from PostgreSQL to MySQL

I set up a website using Drupal 10 and PostgreSQL but due to a communication delay, I just found out from the server team that the database on the staging/live servers is MySQL and not PostgreSQL. I ...
GeorgeCiesinski's user avatar
0 votes
0 answers
21 views

MSSQL - How to get a list of documents from a node that is using a space and a view?

I have a list of documents that are associated with a node of type space. The space has a page with a view and filter to list documents only related to that node. I'm trying to query the database to ...
Charlie Boy's user avatar
2 votes
1 answer
79 views

Paragraph Entity Query returns too many results

I'm trying to find a paragraph that have a certain taxonomy term value and on a matching parent node. I tried the code below, but it always returns over 30 values, when really only one paragraph ...
Rene's user avatar
  • 111
0 votes
0 answers
26 views

How to change the default database driver to the SQLite option in profile installation?

I have two database driver options in the "database setup" step while installing a Drupal project from a custom profile. By default, the MySQL database is selected. But I want it to choose ...
Tasneem's user avatar
  • 95
-1 votes
1 answer
86 views

Using common database for multiple developers in local environment gets slow

When use the common database to develop in local environment for multiple developers in one Drupal 9 project is getting too slow. This issue occurs on Drupal sites only, others (Wordpress, Laravel, ...
Sukanya Sathyan's user avatar
1 vote
1 answer
336 views

Can I use entityQuery() in a Drupal 10 site to query entities from a Drupal 7 database?

Can I use entityQuery() to query entities in a Drupal 7 table? I know it's possible to change the active database and then use a dynamic query to access the database, but can I do that also with ...
arnoldbird's user avatar
  • 1,173
0 votes
1 answer
75 views

Condition that deletes rows older than 30 days

How can I query a condition that deletes the rows with column Date older than the last 30 days in DBTNG format? I have tried this, but it's wrong. $connection = \Drupal::database(); $connection->...
Ricardo Castañeda's user avatar
0 votes
1 answer
28 views

DBTNG sentence that sums a column from all rows of a specific user and dpm the total

This is my table test_sum_expression with columns: uid (int) Stores the UID of the user. points (int) Stores a number. I have this SQL sentence which SUMS all points from user with uid 1. SELECT uid, ...
Ricardo Castañeda's user avatar
0 votes
1 answer
122 views

Database addExpression SUM: Call to a member function execute() on string

I need to get the sum of all points values of the user with uid 1 from the test_sum_expression table. But when I try to execute I get this message Error: Call to a member function execute() on string....
Ricardo Castañeda's user avatar
5 votes
0 answers
57 views

Prioritise condition in QueryInterface

I have an overview with a search field. The query should search on both the title and description, but I would want to show my results that have the search parameter in the title first in the list. I ...
Cedric Lenders's user avatar
-2 votes
3 answers
99 views

Get the HTML content from the database [closed]

I have a copy of a Drupal 9 database from which I need to download all the pages. I loaded the database in MySQL Workbench CE and connected to it via Python. There are many tables, but no views or ...
user21365078's user avatar
0 votes
1 answer
231 views

The specified database connection is not defined: default for Drupal drush

I have the following configurations for my Drupal site: sites/mysite/settings.local.php $databases['default']['default'] = array( 'database' => 'mydb', 'username' => 'root', 'password' =&...
Happy Coder's user avatar
1 vote
1 answer
127 views

Schema insert row only if primary key doesn't exist

I'm doing an exercise where I have a table called visit_counter with fields uid (primary key that stores the user id) and user_visit_count (sum of user's page visits). The purpose of the table is to ...
Ricardo Castañeda's user avatar
0 votes
1 answer
48 views

How to delete a no longer used custom bin table?

I'm testing the cacheAPI with a custom bin. Everything is working. On the other hand, while testing, I created a custom bin with a name that does not suit me. cache.lorem_bin: class: Drupal\Core\...
Sébastien Gicquel's user avatar
0 votes
0 answers
25 views

Special sorting requirement in views for a multi-value field: how to avoid duplicated result items

This is another attempt to solve Custom views filter plugin: filter over two fields of a custom entity where one of the fields is a multi value field in a seperate table I have create a basefield (...
Tobias Krause's user avatar
1 vote
1 answer
74 views

While upgrading from D6, update.php appears to expect the Drupal 7 version of the database array and it throws errors

Leaving settings.php in place (but writeable), per instructions 13 + 14 of major upgrade section of https://api.drupal.org/api/drupal/UPGRADE.txt/7.x , with the new D7 codebase but the old D6 DB, i ...
john brush's user avatar
1 vote
2 answers
116 views

Custom views filter plugin: filter over two fields of a custom entity where one of the fields is a multi value field in a seperate table

I have a custom entity with two basefields of type "list_string": "role" and "additional_role". I need this as "role" is used for sorting the entities by a very ...
Tobias Krause's user avatar
-2 votes
1 answer
91 views

How can i subscribe/unsubscribe to a simplenews newsletter programmatically?

I have the following code to set subscriptions to a simplenews newsletter on or off: $user_load = User::load($userID_current); $newsletter_subscriptions = [ 'newsletter1' => 'on', ...
Tobi's user avatar
  • 23
0 votes
0 answers
37 views

Auto increment value less than max uid on users table

I'm seeing these errors flooding my log file. They come from commerce order complete pages - and some registration pages too. Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity ...
Wayne Foster's user avatar
1 vote
0 answers
48 views

How to add groupBy option WITH ROLLUP

With Drupal 9.5.3, a group by like this: $query->groupBy("myfieldname WITH ROLLUP"); will result in (...) Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not ...
MSNOP's user avatar
  • 11
1 vote
0 answers
29 views

How can I find all the nodes that use a hierarchical vocabulary taxonomy term and reference a child term but not its parent term

I am using Drupal 7. I have a content type "Public Resource" that uses a hierarchical vocabulary called "Resource Topics" that has up to 3 levels (parent->child->child of ...
Matt Pugh's user avatar
4 votes
0 answers
148 views

How can I dynamically switch between two databases for ALL queries?

I need to copy some entities from one Drupal 9 database to different Drupal 9 database. I have searched and looked high and low, but none of the examples I have found work anywhere. I found no help on ...
Martin Joergensen's user avatar
0 votes
1 answer
48 views

How do I enable all error messages altering directly a database table?

When I try to log in on a site, I get a generic error, which doesn't help in understanding what exactly is going wrong. I would like to enable the All messages, with backtrace information option shown ...
-1 votes
1 answer
1k views

Unable to connect to database when launching a new Drupal site with Lando [closed]

I tried to set up a new local drupal9 site using Lando, but it is unable to connect to the database and I am getting the following error. Failed to connect to your database server. The server reports ...
shibasaki_stack's user avatar
0 votes
1 answer
367 views

Database update doesn't work after update from 9.2 to 9.3

I have unfortunately not found anything that seems to solve my issue. My Google-fu may be defunct. I have upgraded a Drupal site from 9.2 to 9.3. This works as expected with composer (I use drupal/...
Angus's user avatar
  • 51
0 votes
1 answer
50 views

How can I delete properly an old translation string?

I found an old string into locales_source table, like that: The associated 8.5.3 version seems outdated. I would like to understand the usefulness of the keep this data in my database ? How to clean ...
florian_drupal's user avatar
1 vote
1 answer
216 views

Migrating from D7 / MySQL 5.6 to D9 / MySQL 8

I've read the documentation of upgrading (migrating) from D7 to D9, but didn't see anything about how to handle changing MySQL versions in the process. My D7 instance is on MySQL 5.6, which is ...
leducvin's user avatar
0 votes
1 answer
286 views

How to get fields of a product type using a database dynamic query

So I currently have multiple different product types that have varying fields. I was able to fetch all products using EntityTypeManager the following way: $productStorage = \Drupal::entityTypeManager()...
levente.nas's user avatar
-2 votes
2 answers
230 views

SQL error in Module

I'm trying to query the database inside my module, but I get this error. Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in ...
arnemichiels's user avatar
1 vote
0 answers
2k views

Argument 2 passed to Symfony\Component\Routing\RouteCollection::add() must be an instance of Symfony\Component\Routing\Route, boolean given

Ubuntu 18.04.6 Apache2, Postgresql 10, Drupal 8.9.6, PHP 7.2.34 (most of the modules require these versions) I've tried trouble shooting this problem for multiple weeks. I'm attempting to migrate a ...
Nategamer's user avatar
0 votes
1 answer
122 views

How can I collaborate with multiple developers? [closed]

I am developing a website on Drupal with 2 other developers. What would be the best way to collaborate? We plan to work on different git branches and there will be a dev and production branch as well. ...
ABHISHEK Joshi's user avatar
3 votes
2 answers
241 views

Where is it documented that fields included in the entity_keys are 'required' regardless of the required property value in the field definition?

I've created a custom entity. One of the fields I've added is an entity reference field that was created calling BaseFieldDefinition::setRequired(FALSE). When I installed my module and tried to add a ...
chickenug8's user avatar
-4 votes
1 answer
180 views

Access denied in Drush but granted in GUI [closed]

I am trying to install Drupal on a CentOS based shared server environment (namecheap.com) with mysql, ssh and Composer. I have created a database username and a database with the same name and a ...
houdy's user avatar
  • 9
1 vote
2 answers
565 views

How to display results database query in a custom block

This is my first post - so hello everyone :) I am trying to write a custom module that displays a certain number of posts from a certain category. I need a few of these blocks to display posts from ...
arek_s's user avatar
  • 9
1 vote
1 answer
439 views

Delete a custom field from node_field_data table

A custom module added a field to the node_field_data table. Deleting the field in a hook update like this: function HOOK_update_N() { Database::getConnection()->schema()->dropField('...
esod's user avatar
  • 319
-3 votes
1 answer
78 views

How to change a text with one dynamic term in all nodes? [closed]

I have a core website, no contrib modules or themes are installed. All my nodes, from several content types, start with the following text, which is written in WYSIWYG CKeditor. The term X is used to ...
alkomosi's user avatar
1 vote
0 answers
47 views

Multiple value field create duplicate results when using leftJoin

I have a query to the database for a specific content type. Everything is working as expected but when I add a leftJoin query on the field 'node__field_country' which is a taxonomy term reference ...
Black coffee's user avatar

1
2 3 4 5
63