Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [database]

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

-1
votes
1answer
22 views

Drupal maintenance over several environments

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
1answer
60 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
43 views

How do I extend Drupal\Core\Database\Driver\mysql\Select?

Currently, my website uses MySQL. I want to override some methods on the Select when I use the following code. $query = Database::getConnection()->select('my_table', 'my_table'); $query->...
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
64 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 ...
-1
votes
0answers
11 views

Content type profile stopped saving new fields, editing old fields still works

My student association still uses an ancient drupal 6 website, I am currently working to recreate it in drupal 8 but until then the drupal 6 site is still critical. The server running the site was an ...
0
votes
0answers
25 views

How to turn my database values into a Entity Object?

I have a form I am creating that should put in the User Entity ID of whoever assigned the task. The code below gives the following error: InvalidArgumentException: The #default_value property has ...
0
votes
1answer
40 views

How can I query a Drupal 7 database from Drupal 8?

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
47 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
14 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
votes
0answers
16 views

How to use Ajax to dynamically render a new paragraph with DB data?

I'm kinda starting with Drupal 8 and I need some help. I have a dropdown in a custom block which options are taken from a DB. Now, I would like to create an Ajax callback that could take the value ...
1
vote
0answers
14 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
16 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
0answers
35 views

Data entry interface?

I'm trying to create simple web-app. In a from-scratch approach I will first create my db-schema. From what I understood the equivalent of db TABLE in Drupal is Content-type. So I created one, added ...
-2
votes
0answers
11 views

Error when creating Pie Chart in Charts Module

When I try to create a pie or donut chart it gives me this error message: "Cannot read property 'color' of null". All other chart types work. Any idea why the module returns this error or how to fix ...
-2
votes
2answers
26 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
43 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
17 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
24 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 ...
-1
votes
1answer
48 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, ...
-2
votes
1answer
36 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/...
0
votes
0answers
9 views

Select statements against postgres table are returning null

I have a table, edm_info, located on the same postgres database as my drupal 7 site. I want to display information from the table on my drupal website. Using several different methods, I have ...
0
votes
1answer
11 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 ...
0
votes
0answers
34 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?
1
vote
1answer
30 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 ...
0
votes
0answers
29 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 ...
0
votes
0answers
112 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 ...
0
votes
0answers
37 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 ...
-2
votes
1answer
28 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 ...
0
votes
1answer
22 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 ...
0
votes
1answer
24 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 = ...
1
vote
1answer
30 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, ...
1
vote
1answer
32 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 $...
3
votes
2answers
116 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 ...
0
votes
1answer
23 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 ...
0
votes
1answer
15 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 ...
2
votes
1answer
90 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 ...
1
vote
0answers
41 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 ...
1
vote
1answer
207 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: ...
0
votes
0answers
26 views

Is it safe to upgrade all the tables for 4 byte UTF-8 support?

I've a Drupal 7 website and it's a news website. To embed Tweets with smilies in my content, I had to add 4 byte UTF-8 support to the content table, following Multi-byte UTF-8 support in Drupal 7. ...
0
votes
2answers
42 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 ...
0
votes
1answer
79 views

How to write SQL Statements With Spaces In Column Names

Hi I am trying to write a Dynamic Query to get data from the database but I am facing issues to write a query for column names with white spaces. My Product_Details Table looks as below: | S.No. | ...
0
votes
0answers
45 views

Custom query using EntityFieldQuery

I need to add a validation and need to check if an event booking (start and end time) falls under already booked time (start and end time). So far, I have done as below, but it is not working as it ...
-2
votes
1answer
28 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(); ...
0
votes
0answers
12 views

How to fetch records from entity base on 6 month

How to recover records from the entity database for the previous 6 months DATE_FORMAT (CURDATE () - INTERVAL 6 MONTH, "% Y-% m-01") is not supported For example: $database = \Drupal::database(); $...
-1
votes
2answers
99 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 ...
0
votes
1answer
159 views

Display database query results in custom module

I have a custom block and I'm able to update its content using #pre_render if I'm using basic text. However I'm unable to print database query results using the same way. Below is my code. function ...
0
votes
1answer
69 views

Why am I getting Your system schema version is -1

I'm trying to make database updates to my Drupal 8 website, but I keep getting the error Your system schema version is -1. Updating directly from a schema version prior to 8000 is not supported., ...
0
votes
1answer
37 views

backing out of a module update after uploading it and before the database update (new update is incompatible with my version of PHP)

I got a situation here and I don't know what to do. Drupal 7. There's an update for reCAPTCHA so I click the button and checkboxes and whatever to update it, it uploads the files to the server and ...
0
votes
1answer
41 views

Is upgrading MySQL to MariaDB seamless for Drupal sites [closed]

My server has an outdated version of MySQL (5.5, which EOL'd in December). The WHM panel has an update option and the recommended upgrade is MariaDB 10.3. In theory (with all usual "test first" ...