Questions tagged [database]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
23 views

Optimizing MySQL on a dedicated server [closed]

There are some doc on this topic, but it doesn't cover my use case: I have a brand new server running Ubuntu 18.04 and I use it only to run MySQL (another tower is running apache/Drupal/PHP/...) ...
0
votes
0answers
22 views

How to know if a field_config_instance is safe to delete

What I did, and my findings: I installed commerce_product_bundles module for D7, and found that it leaves 5 orphaned field_config_instances in the database after uninstalling: commerce_unit_price, ...
1
vote
1answer
44 views

I cannot delete Devel generated content because I get an error about a not existing table

I'm trying to delete some generated content but I get an unhandled exception in the log. Drupal\Core\Entity\EntityStorageException: SQLSTATE[42S02]: Base table or view not found: 1146 Table '...
1
vote
1answer
24 views

How do I compare fields in a database query?

Given the query fragment: $query = $connection->select('mytable', 't'); $query->addField('t', 'myfield1', 'myfield1'); $query->addField('t', 'myfield2', 'myfield2'); I need to add a ...
0
votes
1answer
12 views

How to query for a list of tables in a secondary database

I'm working on some Functional tests on a secondary database. Part of the tear down process is to drop tables in the secondary database. How do a make a query like 'show tables' where I can iterate ...
0
votes
2answers
34 views

PostgreSQL unbuffered query

I am producing large query results that can exceed a sizable PHP memory limit (128 Mb). I've been trying to address this and came across unbuffered queries. Unfortunately, these only seem to be ...
-1
votes
1answer
18 views

How to Update db field value in hook_menu()?

I'm using Drupal 7, my requirement is to automatically update the node field value in a content type for a condition. I have used Hook_menu() for to get a link and if i use that link my code will ...
0
votes
0answers
32 views

How to solve “Query failed” error in drush sql-sync output 2?

I have the exact same problem as in How to solve "Query failed" error in drush sql-sync output?, exact same output. That user found the answer as the password in settings.php was wrong, but ...
0
votes
0answers
16 views

db_select with groupBy(CAST(column as DATE))

I am looking to achieve GROUP BY CAST(date_time AS DATE) in a db_select function in Drupal 7 but with no idea how. The function up until now is: foreach ($distinct_users as $user){ $day_record =...
0
votes
1answer
29 views

Can I use the Migrate module to sync a site database with a Filemaker Pro database?

Is it possible to get data from a Filemaker Pro database and insert it into the database for a Drupal site? Ideally, I'd like to set this up so that Drupal would periodically check the Filemaker ...
1
vote
1answer
45 views

How to create a user with custom fields?

On my drupal site, using the User module, I have added extra fields to the user registration form such as 'Organization'. I notice that this has created a mysql database called '...
0
votes
0answers
70 views

There was a problem creating field: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

I've recently downloaded a Drupal website to work on a local host (xampp). After importing the database, changing the base_url and running the update.php script, I managed to make it work. However, ...
0
votes
2answers
41 views

EntityQuery for taxonomy term of specific bundle

I would like to build a query for all taxonomy terms of a specific bundle. $terms = \Drupal::entityQuery('taxonomy_term') ->condition('type','mail_template') ->execute(); This returns an ...
0
votes
1answer
39 views

How to find a field name/column name of a field in database where I have only the label of that field?

I am working on an integration part with drupal framework. Here it's hard to find the table names of the field which is present in the view as I know only the field label name. Is there any way to ...
1
vote
1answer
18 views

Database API and Security

I'm working on a controller that queries a table based on the value in a route parameter Example route path: path: '/path/{parameter}' Controller: public function myFunction($parameter) { $...
0
votes
0answers
48 views

how to convert a timestamp into a date format in a custom module [duplicate]

I created a custom module and printed this outcome in .csv. Name,Event,Email,Timestamp Ea Iustum Jus,Fifa,example@asdf.wer,1573924224 How do I convert the timestamp in a date format? I tried with $...
2
votes
2answers
223 views

Where is the node created timestamp stored in the database?

I need to create an SQL query that finds all nodes of a certain type created X days ago, so I can get their IDs. Due to the massive number of nodes in the database, I would prefer to use a direct SQL ...
0
votes
1answer
15 views

Database Abstraction to Fetch published content of specific content type throwing error

I'm attempting to grab all published content of type 'homepage_slide', as currently my slider loads all content unpublished or otherwise. Here is my current Abstraction query. if ($variables['...
0
votes
0answers
29 views

Querying entities taking an insane amount of time

Is the entity system in D7 not very well optimized? I am trying to iterate through 1500 entities using EntityFieldQuery(), and I had to extend my execution time to 300 seconds in order for the ...
1
vote
1answer
46 views

What is error: “Base table or view not found: 1146”

Base table or view not found: 1146 Table '(database).(entity)__(field_name)' doesn't exist I have problems running my site since i deleted field (field_name) from entity (entity), to be clear entity ...
0
votes
0answers
29 views

How to get only published revisions of a node?

I have several types of content that are moderated(content_moderation and workflows), in a custom validation process I need to know if a particular node has at least one published revision. Is there a ...
-2
votes
1answer
43 views

Installing a module on a separate database

I currently have a Drupal 7 site with a big database. I have to install the Drupal Commerce module and I would like to install the module using a separate database. I know I have to setup the second ...
0
votes
0answers
54 views

Notice: unserialize(): Error at offset XX (removing Paragraphs)

I'm trying to remove Paragraphs and modules related to it manually (because I can't remove it completly from admin page). I'm using UTF8 without BOM in Notepad++ when editing key_value BLOB file that ...
0
votes
0answers
18 views

How to disable all webform modules from phpmyadmin [duplicate]

How can I disable all modules related to the webform (WEBFORM EXAMPLE, WEBFORM DEMO and WEBFORM) from the phpmyadmin? Since I installed them all I am unable to access the admin panel. It does log in ...
1
vote
0answers
92 views

Drush cannot connect to the database when updating

I am trying to update Drupal from version 8.7.5 to 8.7.7. I installed Drupal using composer and had a really old version of Drush that I had installed from apt-get. I uninstalled the old version and ...
1
vote
0answers
21 views

How to create a query nodes, that queries content with more than one comment?

Consider this example: $query = \Drupal::entityTypeManager()->getStorage('node')->getQuery(); $nids = $query->condition('type', 'question') ->condition('status', 1) ->...
0
votes
0answers
13 views

Items removed from Node Reference field are still displaying on the node

This problem only very recently cropped up; I've never encountered it before. I have a content type (Resource) that contains a Node Reference field (pointing to Organization nodes) that allows ...
1
vote
0answers
31 views

Delete user in transaction

I'm having trouble figuring out why the following code isn't working in Drupal 7. _queue_processor is a cron queue processor function: function _queue_processor($uid) { $transaction = ...
0
votes
0answers
32 views

How to add a UNION to a query in hook_views_query_alter?

I have a custom multiple-value field (via plugin) in a bundle that needs to have an dynamic entry added prior to rendering in the view. I've tried render hooks. The problem is that if there are ...
0
votes
1answer
32 views

How can I run a Views SQL query in PhpMyAdmin?

i go to admin/structure/views/settings, check Show information and statistics about the view during live preview and then Show the SQL query checkbox that will appear below. I have a field which is ...
0
votes
1answer
77 views

How to save the webform data to custom table?

I designed a student registration form using webforms module. My requirement is to save data from the form to table student. How can i achieve this? Is there anyway to mention this in configuration ...
0
votes
0answers
25 views

Expose custom db table to views to join with any entity data

We have a db table from custom module which has fields entity_id and entity_type. I need to exposed this table to views using hook_views_data() and it should be possible to join with this table within ...
1
vote
1answer
67 views

Can I get integers from a dynamic query using fetchAllKeyed?

So basically I want an array of integers from a query using fetchAllKeyed for the results. The field is an tinyint in the db so I would expect an indexed array of integers but I am getting an ...
1
vote
1answer
41 views

Fetching node field values programmatically

I have figured out how to query the node table programmatically without using the deprecated db_query() function. However, I soon discovered that the actual content fields are not held in the node ...
0
votes
1answer
12 views

Entity wrapper save using db_transaction()?

I am using a db_transaction() for some data updates. I am using some EntityMetadataWrappers, modify some data, then save. The thing is, the wrapper ->save() function doesn't have a parameter for $...
1
vote
2answers
50 views

Is it normal for a database to have 3600 tables?

I recently inherited a Drupal site and while trying to migrate the site and DB I noticed that the DB is 1GB+ and had 1000s of tables. This is the first time i work with Drupal so I'm not sure what ...
1
vote
3answers
21 views

Query fieldCondition for custom content type

I am attempting to query a custom content type called players (machine name) in a Drupal 7 module and it seemed to be working fine up until an hour ago. Nothing has changed on my side but now the '...
0
votes
1answer
30 views

Add second expression to query

I have a probably trivial question, but I could not find an answer. I have this query, which works fine: $query = db_select('books, 't'); $query ->fields('t', ['publication_year']) ->...
0
votes
0answers
38 views

Primary-replica using PostgreSQL

I have master-standby servers on PostgreSQL working perfectly. I followed Database Configuration and edited the settings.php file to contain the following code. $databases['default']['default'] = ...
-1
votes
1answer
67 views

How do I pull data from an external database, and display it in Views? [closed]

I am fairly new to Drupal, and just started working with Drupal 8. I know a table can be generated in Views for the content which is displayed/used somewhere on the site, and a table can also be ...
-1
votes
1answer
35 views

List files in a directory as a table

I created a folder inside of my Drupal directory where my client can directly FTP into and upload or remove PDFs. What I'm trying to do is create a page called "Documents" which then displays all ...
0
votes
0answers
21 views

Can a cached query being used as another query select?

I've got a query as follows : $selected_services = array(512, 825, 912, 913, 936); $query = db_select('users', 'u'); $query->join('users_roles', 'ur', 'ur.uid = u.uid'); $query->join('role', '...
1
vote
1answer
29 views

Looking for core Drupal table DDLs

My Drupal 7 installation has a handful of tables that have been corrupted. Attempts to repair them have not been successful so my best chance of being able to move forward is to recreate them. I have ...
4
votes
1answer
518 views

Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

I have always known that loading multiple nodes at the same time is faster than loading them one by one. What I wasn't aware of, is the huge performance difference between the two ways of loading ...
0
votes
0answers
5 views

Unable to install site when attempting to upload a Background Process module

We recently added a new module Background Process to our local drupal environment by running the command drush en background_process -y. After installing, I was able to use the method ...
0
votes
0answers
72 views

Listing two different custom entity types in one view

We defined two entity types, questions and answers. They are related to each other but we will need a view listing all questions and answers in order of title or created date for example. When you ...
2
votes
1answer
31 views

Is there a way to get the max size of a varchar textfield?

I have an entity with a textfield created using the core Fields feature that looks like this when I inspect the type of the field table in the database varchar(40). I want to be able to determine max ...
0
votes
1answer
100 views

Where in the MySQL database schema is the URL alias for a group relation?

I am building a report outside of Drupal that pulls data from a Drupal 8 database. The report shows titles of different nodes and I want to link those titles to the web page for that content. This ...
-2
votes
1answer
21 views

Slow page load (seemingly large pulls from MariaDB)

We have a Drupal 8 site running on Windows/Apache/PHP7.2 that pulls data from a MariaDB server (on a different subnet - ie not in our DMZ) also running Windows. When a user is signed in to Drupal the ...
-1
votes
1answer
168 views

Fetch and update with foreach loop

I need to update the database. the code I am using was working, but after I have done some Drupal updates, it doesn't work anymore. I'm fetching data from table all is working but when I add code ...