Questions tagged [database]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
17 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
10 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
28 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
25 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
24 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
34 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
17 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
49 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
29 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
9 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
47 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
19 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
21 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
30 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
46 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
31 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
19 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 ...
5
votes
1answer
464 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
4 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
25 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
30 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
40 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
19 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
50 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 ...
0
votes
1answer
75 views

Delete a field from the database manually

I installed a module that left a ghost field that isn't tied to any entity bundle :( How would I go about safely and thoroughly deleting this field from the database? I have to delete this field to ...
-2
votes
1answer
20 views

Is there a way to determine creator of each table on an existing Drupal DB?

I am investigating Data Science stakes for a company and have started by exploring the data they have. They are running their website on Drupal (7.59), which, compared to a "traditional" relational DB ...
0
votes
0answers
14 views

Add a FULLTEXT index on specific column

I'm currently implementing a custom search engine in my custom module. In order to optimize my module, I would like to perform SQL queries by using the syntax MATCH....AGAINST in Entity queries. By ...
1
vote
1answer
30 views

How can I display custom data from the database in a View?

I'm working to create a new website in Drupal 8 and cannot figure out how to reference custom table data within a View. Specifically, I have a script that is taking data from an external DB and ...
0
votes
2answers
36 views

How to query external database for Count

How do I query the below SQL query to an external database table from Drupal 8 custom module, Select Count(requestID) FROM requestDB.request where request.dateCreated >= DATE_SUB(CURRENT_DATE, ...
0
votes
0answers
20 views

InnoDB not locking a SELECT statement using db_query()

From Any way to select without causing locking in MySQL? I found a way to implement a select query in a InnoDB table without locking. The example code given there is the following. SET TRANSACTION ...
0
votes
1answer
47 views

How owerride entity node delete core function

I'm doing a headless drupal cms. I need to check the entities before they are deleted. I need to do it globally as the deletion of entities can take place via api (already written) or by using the ...
0
votes
0answers
17 views

Installation on Oracle database using the Oracle driver

I have been trying to install/host Drupal 7 on Oracle Database as the primary database for last few days without any luck. Here is the Oracle driver link that I have looked at https://www.drupal.org/...
0
votes
1answer
30 views

Extra Content Appears Below Footer

I have an issue where I have the page for a specific role showing up on every page and additionally an error message. These show up below the footer on the pages. I've gone through the theme files ...
0
votes
0answers
44 views

Install in a specific PostGreSQL schema

I want to install & setup my Drupal databases in a specific schema of the PostgreSQL database. For example, let's say I have created a schema named "test_drupal" in my existing PostGreSQL database ...
0
votes
0answers
41 views

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1074 Column length too big

I am trying to update my database collations to utf8mb4 to support more characters (like emojis etc.) following this guide: https://www.jeffgeerling.com/blog/2016/getting-emoji-and-multibyte-...
0
votes
0answers
17 views

File uploading issue

We're having issues uploading files. Some files encounter an error message that states The specified file temporary://p1dah901n910tl8lv14.tmp could not be copied, because no file by that name ...
-1
votes
1answer
36 views

Drupal maintenance over several environments [closed]

I have a production environment for a Drupal 7 site. This environment is replicated to a staging environment, which we use for testing updates to modules and drupal core (same major version). We ...
0
votes
3answers
871 views

How do I perform outstanding entity updates after 8.7?

I have just tested the update to 8.7.1 (from 8.6.x) which includes the removal of the old automatic entity update functionality, which means drush entup no longer works. As far as I understand the ...
0
votes
0answers
8 views

use TableSort with multiple database tables?

I have a custom module where i want to show a table on a page. The rows of this table are the representation of a list of objects stored in database table A. Most of the columns show data from ...
0
votes
1answer
151 views

Error when upgrading to Drupal 8.7.1 on module menu_link_content

When running database updates (on domain.com/update.php) from 8.6.15 to 8.7.1, I got the following error: module menu_link_content Update make_menu_link_content_revisionable Custom menu links have ...
0
votes
1answer
55 views

How can I query a database created using the previous core version from the new core version?

I want to query users, nodes etc in my D7 database that I am currently migrating to D8 to compare with the migrated content. I want to use custom Drush commands to run some checks. Is this possible?
0
votes
1answer
263 views

Get node based target id from entity reference

We have an Article content type which has an Entity Reference field called field_document that is linked to the Media bundle type of Document. In mymodule we need to write a hook that will take the ...
0
votes
1answer
16 views

How do I apply an OR condition?

I've got the below code $query = \Drupal::database() ->select("excel", "e")->fields("e"); $group = $query->orConditionGroup() ->condition("grupindex", 1) ->condition("grupkodu", ...
1
vote
0answers
24 views

How to alter SQL queries in theme layer in Drupal 8?

In Drupal 7, we could use hook_query_alter() in theme layer since drupal_alter() made modules and theme run the alter functions, but in Drupal 8, it seems this as been restricted to custom modules....
0
votes
0answers
18 views

get value of select dropdown

I'm trying to take values from dynamic select boxes I retrieve them from the database here is the code foreach ($courses as $course) { $query = db_select('Lab'); ...
-2
votes
2answers
28 views

How to create a rule and inject mysql code?

Can I create a rule on my drupal 7 website and that rule will: Whenever a user is logged in (only logged in users can see this content) and a certain content is clicked I want to write a mysql update ...
0
votes
1answer
86 views

How to chart data stored in a database table (dynamically) in Drupal 8?

I found these instructions for using the Charts module to display data from a database for Drupal 7: https://www.drupal.org/docs/8/modules/charts/charts-howtos/chart-some-data-stored-in-a-database-...
0
votes
1answer
21 views

How i can create VIEW table using Drupal hook_schema()

i want to create a view table in my custom module .install file and i want join with another table like i did in my db_query function but i want this thing in hook_schema function. db_query('CREATE ...
0
votes
1answer
25 views

logging into development instance of Drupal

Ive rsynced the directory structure from mywebsite.com to mywebsite.local ( on my LAN) and copied the DB . the website mywebsite.local displays the website, but i cant log with the admin user/pw ...