Questions tagged [database]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
62 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 ...
Zeinab Abounassif's user avatar
1 vote
3 answers
116 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 '...
Wally Kolcz's user avatar
0 votes
0 answers
185 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']) ->...
Xyarvius's user avatar
-1 votes
1 answer
847 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 ...
Junaid Tahir's user avatar
-1 votes
1 answer
270 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 ...
hisusu32's user avatar
  • 101
1 vote
1 answer
40 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 ...
Dave's user avatar
  • 133
7 votes
2 answers
2k 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 ...
user avatar
0 votes
0 answers
421 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 ...
Tobias Krause's user avatar
2 votes
1 answer
46 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 ...
Free Radical's user avatar
  • 15.1k
1 vote
2 answers
720 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 ...
Eric Barr's user avatar
  • 111
-3 votes
1 answer
61 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 ...
Stefan Pavone's user avatar
-1 votes
1 answer
728 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 ...
Kristijanas Kiseliovas's user avatar
1 vote
1 answer
3k 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 ...
ymdahi's user avatar
  • 620
2 votes
1 answer
1k 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 ...
CodeLlama's user avatar
0 votes
2 answers
555 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, ...
Akhil Mohandas's user avatar
0 votes
0 answers
51 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 ...
Kannan's user avatar
  • 101
0 votes
1 answer
73 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 ...
Fabio Marsigliano's user avatar
-1 votes
1 answer
56 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 ...
Miguel Mesquita Alfaiate's user avatar
4 votes
3 answers
7k 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 ...
MoritzLost's user avatar
0 votes
1 answer
477 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 ...
Marcos Buarque's user avatar
0 votes
1 answer
70 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?
dibs's user avatar
  • 818
0 votes
1 answer
4k 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 ...
usernameabc's user avatar
  • 2,686
0 votes
1 answer
25 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", ...
Kartagis's user avatar
  • 612
1 vote
0 answers
116 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....
Joshua Graham's user avatar
-2 votes
2 answers
37 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 ...
Paul's user avatar
  • 11
0 votes
1 answer
58 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 ...
ALI's user avatar
  • 15
0 votes
1 answer
29 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 ...
user358360's user avatar
4 votes
1 answer
2k views

Is MySQL 5.7 compatible?

My server has been on MySQL 5.6 for quite awhile and now I need to upgrade to MySQL 5.7. Is it safe to upgrade to 5.7 for all of my Drupal 7.x sites? Just doing a quick google for drupal 7 mysql 5.7, ...
Patoshi パトシ's user avatar
-1 votes
1 answer
617 views

Strategy for Import/exporting Drupal8 as content and structure

We are setting up feature>dev>production environments on Platform.sh for a Drupal 8 project. Expecting multiple contributors to the project, we have run into a slight snag regarding Importing/...
dimmech's user avatar
  • 235
0 votes
1 answer
25 views

SQL error when adding an other database table

The Code: In my module.install i am declaring my main database table. This works without any problems: function my_module_install() { create_initial_roles(); drupal_set_message("Installed module ...
Xyarvius's user avatar
0 votes
0 answers
38 views

Drupal Black Box of Death

Does anyone know what it means when drupal appears to fail but displays this black box in the browser?
plambre's user avatar
  • 215
2 votes
1 answer
954 views

How do I join across two different databases?

I have two databases, the normal drupal db and another db to another system. I want to join two tables from these two different dbs. I have already set up the second database using information from ...
rockstardev's user avatar
  • 1,039
0 votes
0 answers
58 views

Efficient way to get entity information

Which is an efficient way to fetch entity label and id? Database query or entity query with entity load? I need to get the list of all taxonomy terms in an associative array of ID and Label. I can ...
Malabya Tewari's user avatar
1 vote
0 answers
4k views

PDOException: SQLSTATE[HY000] [2002] Connection refused Upon Drupal 7 Installation

I have already installed LAMP in my Ubuntu 18.10 server. I have also downloaded Drupal 7 files. But after I navigate to http://10.0.34.74/drupal-7.65/ in my browser. The error below occurs: Error The ...
alyssaeliyah's user avatar
0 votes
0 answers
346 views

Use a custom Table/Storage for a Custom Field

I want to create a DR8 content field, which has no field tables, and passes the save and load mechanisms to a custom table. Is there a way to do this? I've been able to prevent saving with: class ...
jmux's user avatar
  • 111
-2 votes
1 answer
275 views

When will doctrine ORM be implemented for modules? [closed]

I am looking at Drupal for some websites I want to set up. I have been a Symfony developer in the past so would like to use doctrine when I create a custom module. Is it implemented in 9 dev yet? Any ...
MicWit's user avatar
  • 109
0 votes
1 answer
304 views

Custom database connection

What is the best way to connect to a remote database through drupal? Would the correct method be to use the settings.php with the database in there, and use the built in db_select, db_query() etc ...
Ex0r's user avatar
  • 181
0 votes
1 answer
117 views

How do I retrieve media from a reference field?

Inside a node type, I have a reference field to target a media. With a db select, I need to load all related medias of the nodes. For this I use this code: $database = \Drupal::database(); $result = ...
user28220's user avatar
  • 109
1 vote
1 answer
38 views

How to show the following n events with respect to the current date or the past events to always ensure n elements in the view?

I have an agenda on my homepage, and I want to always ensure 5 events. If there are 5 or more following events (including the current one), show the nearest 5 from the start date. If there is less, ...
Maxi Castro's user avatar
1 vote
1 answer
41 views

Delete in lieu of truncate?

If my DB user doesn't have permission to truncate a table - would using delete instead without any parameters be equivalent? So like - $this->db->delete('data')->execute(); in lieu of $...
user7355700's user avatar
3 votes
2 answers
3k views

\Drupal::database() ->insert - Error: Call to undefined method Using ->condition()?

I am trying to insert a new row based on conditions. The ->condition() in $database->update() works fine, in $database->insert() they do not. $database = \Drupal::database(); // Query our ...
Prestosaurus's user avatar
  • 2,057
2 votes
1 answer
1k views

Get default value of a node field

I have a field on a node which has a default value set, I need to access the default value of that field. But, I don't want to load any nodes of that type and access the field definitions, nor do I ...
lordZ3d's user avatar
  • 368
0 votes
1 answer
202 views

Add a having condition that makes use of COUNT

I currently have a query that compiles to SELECT n.nid AS nid, field_data_field_date.field_date_value AS incident_date, field_data_field_tweeted_date.field_tweeted_date_value AS tweeted_date, n.nid ...
Amy's user avatar
  • 5,662
2 votes
1 answer
1k views

How to configure mysql database connection with a different socket

I have a Drupal 6 site that I ran for years before walking away about three years ago. I would like to resurrect the site in a more modern CMS and am first considering Drupal 8. I run my site on a ...
Greg Noe's user avatar
  • 131
1 vote
0 answers
116 views

Should I use custom entity types and custom fields to represent complex data types, or is it better to stick with fields and field collections?

Since D7 is now coming up on EOL I need to begin planning the transition of a complex D7 site to D8/9. There are 2 particular data design issues I want to revisit. Number one is that I have a number ...
greendemiurge's user avatar
5 votes
1 answer
2k views

Use another field value as condition in Entity Query

I'm performing in Drupal 8 an entity query that searches for nodes that have not been changed since x days, where x is a numeric node field (node.field_days). So I would like to perform a query like: ...
user avatar
0 votes
2 answers
62 views

How can I insert many field values under one term?

I'm working on a module, of which one function is grab list names and stock codes from a custom table and create corresponding terms. Now, my current code creates a new term and corresponding stock ...
Kartagis's user avatar
  • 612
0 votes
1 answer
3k views

How to write SQL Statements With Spaces In Column Names

I am trying to write a dynamic query to get data from columns with spaces in their names. The Product_Details table is the following. S.No. Product line Product type Product Year 1 Camp Equipment ...
miststudent2011's user avatar
-2 votes
1 answer
70 views

Create dropdown list from values DB

I got some values from the database $result = db_select('node', 'n') ->condition('type', 'staff_members') ->fields('n', array('nid', 'title')) ->execute(); ...
H. Adoorn's user avatar
0 votes
2 answers
904 views

MySQL through SSH tunnel

I'm trying to connect my Drupal 8 website to a mysql database hosted on a different server, which is only accessible through SSH. I can connect my database manager (heidiSQL) with a SSH tunnel, but i ...
Sander's user avatar
  • 11

1
3 4
5
6 7
63