Questions tagged as ['database']

I'm pretty new to Drupal and I'm trying to build a Drupal 7 custom module to alter the user listings table in admin/people. I would like to display the first and last names of the users. I've already added the text fields to the user registration form in admin/config/people/account-settings/manage-fields and I've managed to store the user input in my database table. I've added the extra fields to the us ...
When working on a site I accidentaly removed all my menu items I now want to recover them from a database back-up I have. Is it enough to just copy all data from these tables from the backup to my sites database?
- menu_link_content
- menu_link_content_data
- menu_link_content_field_revision
- menu_link_content_revision
- menu_tree

As an admin I've built a large table on Drupal 8 (php, mysql). It runs without issues for Admin, but trying as Anonymous user it redirects me to core/install.php
Since it's ONLY affecting Anonymous users, I suspect it's DRUPAL 8 that's setting the limit. I want to find where Drupal does that. Anyone can give tips to the specific Drupal 8 files I can look into?
(Resist trying the max_allowed_packet = ...

I have the following menu in my system.
The parent menu-link connects to a node whose ID is 58. All the sub menu-links have a parent ID equal to 58.
I need to find the main and the sub-menus using 58, but I have been unsuccessful at locating the a table that contains that information.
How can I list the nodes that share a particular menu ID?
I am writing a configuration entity modul in drupal 9. I want to list all tables, from an external database (postgis) in the schema called gi. The switch between the databases is no problem. I'm searching for a way, to only get the name of the table called gruenzuege to put this in a markup form.
//the form where to save the table
$form['tables'] = [
'#type' => 'fieldset',
'#title' =&g ...
So I want to QUERY the database for the contents of a field, the trouble is the field is a ckeditor field, so how do I write the condition correctly?
Normally it would be something like this:
$query = \Drupal::entityTypeManager()->getStorage('node')->getQuery();
$query->condition('field_ckeditor_field', $value_to_match); (edited)
But for CKEditor fields there is a _value and _format column in t ...
I have a large array of names and surnames, I need to know which of these differ from the current ones in the database.
For example:
$largeList = largeList();
$storage = $this->entityTypeManager->getStorage("mi_entity");
$query = $storage->getQuery();
foreach ($largeList as $item) {
$andGroup = $query->andConditionGroup();
$andGroup
->condition('name', ...
I have a site with Drupal 9.2.5 and the site was clobbered after installing WordPress in the web root.
I have a backup of the site database, and the sites/default/* files, but I just can't get Drupal up and running again to restore it to the way it was.
I have tried installing again and placing the files back, but this doesn't work.
I have looked at the Drupal docs and searched for migrating or restori ...
I've run into the following error when running the command drush migrate-import custom_spotlight
where custom_spotlight
is the name of the plugin. I've been following along with this guide: https://www.metaltoad.com/blog/drupal-8-migrations-part-4-migrating-nodes-drupal-7 but I'm not exactly sure what went wrong here. It seems when the placeholder :nid
is substituted with a value, there are quotes inserte ...
I'm trying to lock down the database on my Drupal 9 install so that people can browse the website, but can't write to it.
I have 2 users in MariaDB with access to the database. I want to set one account to only be able to write to the needed tables for browsing and give the other account full permissions. To Which tables should the first account have CRUD permissions?
To determine which user to use, ...
I built an entityQuery for a custom entity type "vote". I only want to get those votes for a specific poll and those by deputies who are members of a specific fraction. The fraction membership can change over the time of the legislature so we have an additional custom entity of type "fraction_membership" in which the fraction and the time during which the fraction membership was valid can be set. So wha ...

I had a D9 installation running in MacPorts. I installed docker and docksal, copied the D9 project to the docksal project folder, and uninstalled MacPorts.
Docksal starts up like this:
Starting services...
Creating network "myproject_default" with the default driver
Starting myproject_db_1 ... done
Starting myproject_cli_1 ... done
Starting myproject_web_1 ... done
Connected vhost-proxy to "myproject ...
Attempting to do a join with a LIKE operand in a Views filter plugin. The query looks similar to below; however, when it executes, the LIKE operand is not taken into account and the join is done with '='. Is there a way to do this type of join?
$configuration = [
'type' => 'INNER',
'table' => 'path_alias',
'field' => 'CONCAT(\'%\', path_alias.path)',
'left_table' => ...

I have a SQL query to get all nodes with their ID, title, publish date, change date, etc.
Additionally I need to get path to each of them (probably from path_alias.alias).
Now I have following (without alias):
SELECT MIN(node_field_data.nid) AS nid,node_field_data.type, node_field_data.status, node_field_data.title, node_field_data.langcode AS node_field_data_langcode, node_field_data.created, node_field ...
I have been breaking my head on this issue for a few days now. Using Drupal 9.2.x, I am building a custom field module for a client that has multiple fields. I isolated the problem by only including a managed file field for now, because the other fields are not causing this issue.
I defined a managed file element in my Widget class, which extends WidgetBase:
public function formElement(FieldItemListIn ...
Hello can anybody help with a external Database Connection.
$postgis_database = array(
'database' => $drugis_postgis_connection->getdatabase(),
'username' => $drugis_postgis_connection->getusername(),
'password' => $drugis_postgis_connection->getpassword(),
'host' => $drugis_postgis_connection->gethost(),
'driver' => 'pgsql',
) ...
Currently we are using EntityTypeManager to either load or loadMultiple :
$this->entityTypeManager->getStorage('node')->loadMultiple($nids);
$this->entityTypeManager->getStorage('node')->load($nid);
This creates and returns objects of nodes which I think uses much resource on the server (since it fetches all fields). We're also trying to fetch around 500 nodes, and each has over 80 fie ...
I've trying to add a link to Edit and Delete column to perform desirable actions. I need help in implementing it. I've tried several suggested methods on the internet, but none did the job for me. Maybe I am doing something wrong.
Here is my Controller.php
public function getAdList(){
$limit = 3;
$query = \Drupal::database();
$result = $query->select('ad_form_submis ...
I'm using the fillpdf module with the online FillPDF service to render the PDFs. Most everything is working great; however, if a database field I'm displaying on the PDF contains certain 'foreign' characters, those characters don't display at all.
Notably, this occurs with the circumflex (ĉ) and caron (č) characters. Other foreign chars display fine (eg ö, é, è ...).
Not sure if this is an issu ...

First, I would like to say I am a total noob in Drupal and PHP but possess some knowledge on other web frameworks/languages).
Here is my path to the errors:
I used the UI to install Content Translation and Configuration Translation modules from the multilingual core (other 2 modules were already installed).
This did not work properly as it totally broke the website:
- aliases not respected (from "/co ...