Questions tagged as ['database']

Drupal provides a standard, vendor-agnostic abstraction layer for accessing database servers.
Score: 0
Altering user_admin_account and user_register_form
ro flag

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 ...

Score: 0
Joost avatar
Restore menu items using database backup
jp flag

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
Score: 0
Anonymous user redirected to core/install.php while admin does not
im flag

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 = ...

Score: 0
List all the nodes with the same menu parent ID
pt flag

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?

Score: -3
Steffen  avatar
How to get table names from external DB in non public schema
cn flag

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 ...
Score: 0
RominRonin avatar
Query the database for the value of a ckeditor field
in flag

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 ...

Score: 0
chalo avatar
Multiple unnecessary joins when creating an andConditionGroup()
de flag

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();
        ->condition('name', ...
Score: 1
James Young avatar
Can't restore existing site (no route found for "GET /")
ru flag

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 ...

Score: 0
Sam Ng avatar
Custom Migration Plugin MySQL Error
ck flag

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: 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 ...

Score: 1
blur avatar
For which tables should the MariaDB user have CRUD permissions for browsing the site?
bn flag

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, ...

Score: 1
Tobias Krause avatar
entityQuery returns wrong result: too many joins?
cn flag

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 ...

Score: 0
Cannot access mysql in new docker/docksal/d9 installation
cl flag

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 ...
Score: 2
Wingman avatar
Join with Like in Views Plugin
kr flag

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' =&gt ...
Score: 0
Get path (alias) from SQL query
in flag

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 ...
Score: 0
Smooij avatar
Managed file element in custom field module doesn't save target id
in flag

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 ...
Score: -1
Steffen  avatar
How do I programmatically set a database connection?
cn flag

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',

    ) ...
Score: 0
Gabriel Fernandez avatar
Optimize fetching data from entity objects
cn flag

Currently we are using EntityTypeManager to either load or loadMultiple :


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 ...

Score: -1
Sourabh singh avatar
How do I add link to Edit and Delete in a column in a view table item list?
gp flag

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 ...
Score: 0
peterbe avatar
FillPDF not displaying 'foreign' characters
in flag

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 ...

Score: 0
Content Translation installation breaks the website (statistics module error + aliases not taken into account)
in flag

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 ...