Questions tagged [database]
Drupal provides a standard, vendor-agnostic abstraction layer for accessing database servers.
3,095
questions
-1
votes
1
answer
15
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',
...
0
votes
0
answers
29
views
"The "MenuSettings" plugin does not exist - How do I remove it from the config? [closed]
after Updating my Drupal 8 to Drupal 9 (yes I know there is 10 already out) i can not edit or add new nodes.
Uncaught PHP Exception Drupal\Component\Plugin\Exception\PluginNotFoundException: "...
0
votes
0
answers
43
views
Not sure how to choose between Schema API and Entity API [closed]
I would like to save and then update data fetched from an external API every X minutes.
This data will then be used to display things on the client side.
What is the best practice to store this data ? ...
-2
votes
0
answers
32
views
Using form to create a price calculator [closed]
I want to create a module that will calculate to total price of the computer components selected by the user. It consists of some predefined checkboxes of item names and submitting it would show the ...
0
votes
0
answers
10
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 ...
1
vote
0
answers
32
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 ...
1
vote
0
answers
22
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 ...
4
votes
0
answers
67
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 ...
0
votes
1
answer
37
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
282
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 ...
0
votes
1
answer
89
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/...
0
votes
1
answer
27
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 ...
1
vote
1
answer
95
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 ...
0
votes
1
answer
74
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()...
-2
votes
2
answers
75
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 ...
0
votes
0
answers
534
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 ...
0
votes
1
answer
54
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. ...
0
votes
0
answers
11
views
Can I calculate percentages between two subqueries in addExpression()?
I am trying to calculate the results of two COUNT() subqueries in order to produce a completion percentage. In this case I am getting the total number of courses assigned to an entity then comparing ...
3
votes
2
answers
107
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 ...
-3
votes
1
answer
75
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 ...
0
votes
0
answers
48
views
Uninstalling Commerce Recurring and Commerce License
For some time now, I have been experiencing trouble related to the commerce_recurring and the commerce_licence module. The problems seem to have started to occur once I tried to uninstall the prior. ...
1
vote
2
answers
260
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 ...
0
votes
1
answer
233
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('...
-3
votes
1
answer
56
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 ...
1
vote
0
answers
38
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 ...
1
vote
0
answers
1k
views
I can't import the configuration on production servers [closed]
I am unable to uninstall the MySQL module. I can't import the configuration on production servers when I upgrade Drupal from 9.3.x to 9.4.x.
I get the following error.
The import failed due to the ...
4
votes
1
answer
182
views
Is it possible to have a nested SELECT in a WHERE clause using dynamic queries?
I need to execute this SQL query using dynamic queries.
WHERE (node_field_data.status = 1)
AND (node__field_document_places.entity_id IN (SELECT entity_id FROM node__field_document_places where ...
2
votes
3
answers
102
views
How to check if secondary database definition exists
Can anyone please help me on how to check if secondary database is set. If not throw an error.
I am currently defining database connection as below.
Database::getConnection('default', 'sqlite')
I am ...
0
votes
1
answer
24
views
Access FieldItem object from Widget
I have a custom FieldItem with a method doing a calculation on the field's values:
class MyFieldItem extends FieldItemBase {
...
public function getAmountInEuros() {
$amount = $this->get('...
0
votes
0
answers
47
views
TableSort with entity query aggregate
I'm trying to implement a table sort for a custom Drupal 9.x entity type Packet which represents published medical literature articles which have batched together and assigned for review. Each Packet ...
1
vote
1
answer
472
views
How to solve "Mismatched entity and/or field definitions", specifically, "The URL alias field needs to be installed"?
After migrating from 7.89 to 9.3.12 this warning appears:
ENTITY/FIELD DEFINITIONS Mismatched entity and/or field definitions
The following changes were detected in the entity type and field ...
2
votes
2
answers
148
views
How to use a referenced entity's values in a TableSort?
I have a custom entity with a field which is defined as follows.
$fields['file'] = BaseFieldDefinition::create('file')
->setDescription('Reference to the built-in core File entity type.')
->...
1
vote
0
answers
83
views
Trying to get to the bottom of an out of memory error related to the database
I've inherited a highly problematic site built in Drupal 7. Upon installing the site on my dev space I get a 'This page isn’t working' error 500. Looking at the web logs I get this message:
lmu.[...
-1
votes
1
answer
86
views
Installer can't create sqlite database
I have a drupal page, hosted with azure webapps, on nginx. However, when i start the site, the installer wants to have a database. I am aware that it's bad, but sqlite is an intentional choice because ...
0
votes
0
answers
65
views
How do I set an incremental property on a custom field?
I built a custom module which creates a custom field type (with formatter and widget), and I would like to make one property of the field incremental (to increase its value by one for each instance of ...
1
vote
1
answer
177
views
Does a database transaction rollback if a PHP/Gateway timeout / connection dropped/lost occurs?
I am using Drupal behind a reverse proxy/cache layer (e.g. Cloud Front/ Akamai) and sometimes the service goes quite slow (so I get a Gateway timeout, for reasons such as too many people are using ...
2
votes
1
answer
995
views
How do I get the names of the tables where field data is stored?
In Drupal 7, one was able to retrieve the physical names of the database tables using some code like the following, it was pretty simple.
$field_definitions = field_info_fields();
foreach ($...
1
vote
1
answer
113
views
"[message] => DB Error: no such table" error after installing civicrm
I installed CiviCRM 5.47.3 plugin using composer in the centos 8 server.
my drupal version is 9.3.5
After installing CiviCRM on the server CiviCRM plugin is enabled automatically in admin extension ...
3
votes
1
answer
123
views
How to check which module db updates have been applied?
For a specific module, how can I check which database updates have been applied in Drupal 9? I've downloaded a database from a server and I want to check what the current module schema is.
In Drupal ...
1
vote
0
answers
218
views
EntityQuery, exclude nodes with NOT IN from a multivalued entity reference field
Drupal v. 9.3.8
I recently used the entityQuery command and for simpler queries I had no problems.
Now I need to filter, as well as for the '=' and 'IN' operators, also the nodes, whose multivalued ...
0
votes
0
answers
49
views
Add prefix on tables break my site
I have an old site on an old shared server which used an old shared PHP 5 we can not update. I create a copy of this website which will run on a different (and dedicated) server with PHP 5.6 and ...
0
votes
1
answer
490
views
How do i save a base64 decoded image to file_managed?
I'm trying to save my image to Drupal's file_managed table. However, my image is coming from base64 decode:
$filename = "sign-".$user->id(); // returns "sign-1234"
$image_raw =...
0
votes
0
answers
78
views
Get count of related entities
I have two entities, Post and Category
A Post belongs to a Category via a entity_reference field type name category_id
I want to get a count of posts belonging to a category (To prevent deleting a ...
1
vote
0
answers
314
views
Installing to a MySQL database that requires SSL
I am attempting to install Drupal 9 to a fresh host using an AWS MySQL RDS instance for a database. The database is configured to require SSL. When attempting to install via the web GUI, I receive ...
0
votes
1
answer
106
views
Change a node's type/bundle keep the old type/bundle in field tables
I need to change the bundle/type of some nodes. I tried https://www.drupal.org/project/convert_bundles but there was no way to select just a few nodes and change the bundle/type so I tried the very ...
0
votes
1
answer
779
views
ERROR 1062 (23000): Duplicate entry '/-de' for key 'PRIMARY'
When importing a dump from a production site with mysql in a xampp environment I got this error:
ERROR 1062 (23000): Duplicate entry '/-de' for key 'PRIMARY'
These lines are affected:
ALTER TABLE `...
0
votes
2
answers
441
views
Load node entities by owner
I want to load entities by their owner. This is what I have so far:
\Drupal::logger('migrate_users')->notice("Hello start");
$userStorage = \Drupal::entityTypeManager()->getStorage('...
0
votes
1
answer
63
views
Where are path aliases stored?
I know that, in Drupal 7, path aliases are stored in the url_alias table. Which database table does Drupal 8 use to store path aliases?
0
votes
1
answer
272
views
Problem with database version for drupal 9 db upgrade
Hi I am trying to upgrade drupal 9 on godaddy and when I go to update.php I get this note on the screen...
DATABASE SYSTEM VERSION
5.6.51-cll-lve
The database server version 5.6.51-cll-lve is less ...
0
votes
1
answer
356
views
Search and Replace URL in database?
I need to move a Drupal 9 website to a different server and a lot of links have the old server URL. Normally for Word Press I use this tool - https://github.com/interconnectit/Search-Replace-DB https:/...