Questions tagged [database]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
37 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
376 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
37 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
2k 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
173 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
117 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
81 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
36 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
37 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
37 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
1k 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
69 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
26 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
514 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
66 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 ...
3
votes
1answer
885 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
2answers
49 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
2k 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. | ...
-2
votes
1answer
31 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(); ...
-1
votes
2answers
423 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
1k 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
312 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
56 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
80 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" ...
1
vote
1answer
295 views

Left join query between two custom tables

Hi I'm trying to create a join query between two custom tables. One is publish_options with a pubid as the primary key. The other is publish_options_bundles with a referring field pubid to the first ...
2
votes
1answer
120 views

Have Database Update ignore prefix for multisite with shared database

I currently have a multisite with a single database. Each instance has a different prefix for their tables, except for one with no prefix which is considered to be the main instance. Now there is a ...
2
votes
4answers
1k views

Cannot uninstall modules due to missing table br_schedule

When I hit the Uninstall tab in the UI or try to uninstall a module with Drush I get the following errors: Drush: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DATABASENAME....
0
votes
0answers
47 views

How to get nid as int (and not as string) [duplicate]

This code snippet: var_dump( db_query("select nid, title from node limit 1")->fetchAssoc() ); Prints this: array(2) { ["nid"]=> string(4) "6247" ["title"]=> string(5) "test!" } ...
2
votes
1answer
61 views

Using the fetch() method in database query to get an array

I have a very simple query that does the job, to get a collection of a specific content type's node id and title, that's it. $connection = \Drupal::database(); $query = $connection->select('...
0
votes
0answers
93 views

Where is webforms template info stored in the database

I'm using webforms in Drupal 8. I have migrated an old database over but need to overwrite the correct webforms table to restore a webform template I created on a previous site. Can you tell me ...
0
votes
2answers
90 views

Which method is more efficient, database query or taxonomy term controller?

I tried to find a method to verify if the current taxonomy item page has a parent or children, now I get two but I don't know which one is better for the efficiency. approach I: use taxonomy item ...
4
votes
1answer
517 views

Database 4 byte UTF-8 support not properly checking

In the status report of my drupal website I got the message that I had to up Database 4 byte UTF-8 support. I updated all my tables and database like it's told here: https://www.drupal.org/node/...
-1
votes
2answers
97 views

Database Insert Slower On Production Server [closed]

I recently upgraded the PHP version to 7.1 on my production server. I also updated my local to 7.1 and staging to 7.1. Only on production, I am seeing a slow down when I import a csv file and insert ...
1
vote
1answer
45 views

Programmatically alter a field collection field item not yet saved in the database

Updating field collection field item gives error when one item is added. I have the following code which works well when just changing values of a field already saved in the database but if I add a ...
1
vote
2answers
444 views

How to get image path in view? [closed]

I have created a content type having two fields: Title Image (multiple image field) Then I create a page view for the same. Added these two fields. Now I have to create an external theming in view ...
1
vote
1answer
61 views

How can i use MATCH and AGAINST with db_select?

I have a query like: $query = db_query(" SELECT *, MATCH(field1,field2) AGAINST ('$s' IN BOOLEAN MODE) AS Relevance FROM {my_table} ORDER BY Relevance DESC, created DESC "); That ...
1
vote
0answers
180 views

entityQuery where a translation with a different value returns incorrect nodes

The title seems a bit odd, I know, but I couldn't find any issues similar to this and that's the best I could come up with. We are running into an odd instance of entityQuery returning nodes that ...
0
votes
1answer
437 views

How to display my array values in nested array of type stdClass Object

i am having trouble figuring out how to render my array fields values for specific fields. So far i've managed to query my db and collect the node values and save it to my cart of items. However, i am ...
0
votes
1answer
58 views

Finding entity/webform fields in the database

A bunch of user accounts were deleted and recreated with new UIDs, and so any webform submissions or entities that have fields pointing to the old UID are now broken/wrong. I already updated some UID ...
0
votes
2answers
330 views

Drupal db select IN, group by count

need a bit of help please, when i write my query like this it works fine $query = db_query('select * from form_submissions where address in (select address from form_submissions group by address ...
0
votes
0answers
105 views

Updating the delta value on a custom field

I have a content type with an image field and I am trying to update the delta value. I'm assuming the delta value is used to sort the images when they're rendered. (If there is a better way please ...
0
votes
1answer
229 views

Configure connection to mongodb for querying only

We have an external mongodb instance and we need to query data from it and bring it to Drupal 8 site. On shell this is how we connect (mongodb is running in a different container than drupal) mongo --...
1
vote
1answer
4k views

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: [duplicate]

After entering some custom fields, I went to /content and now I am getting the following error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. I've tried the following with no ...
0
votes
1answer
173 views

Menus, drush uli link, and some images not working after moving site to localhost

I've just gotten a site I'm supposed to do some work on but I'm having trouble with migrating to a local development environment. I don't have admin access to the site itself, but I do have access to ...
0
votes
1answer
71 views

Conditional clauses with Entity field Query

I have a syntax issue on using conditional clauses with EFQ, but the documentation on drupal.org is a bit unclear for me. I have google the whole Internet for this with no results at all. My hook ...
1
vote
0answers
18 views

Select locale translation info from non-default database

I setup 2 databases connections in settings.php, one is MySQL on which Drupal is installed and running, the other is Oracle from which sometimes reading some info non-relevant to Drupal as below: ...
0
votes
1answer
34 views

How do i select all from database and do while loop with them

I did this easy select and im getting Error: Call to a member function fetchAssoc() on boolean , im beginner, im just trying to pull out two variables and make operations with them. $result = ...
1
vote
0answers
65 views

Optimize custom database queries

I am building my first Drupal 8 module and wondering how to optimize work with multiple queries to the database? $query = \Drupal::database(); $transaction = $query->startTransaction(); $product = ...
4
votes
1answer
659 views

Per bundle storage?

In Drupal 7 there was the start of Per-Bundle Storage (PBS) to try to store field data in a single database table if that made sense and was possible given the nature of the field. The PBS for Drupal ...
-1
votes
1answer
17 views

How can I add an array or a new value to the query condition? [closed]

I need to add a new type of content in my query condition, but I don't know how to do it. This is the code I am using. $query_result = $query->getQuery() ->condition('type','series'+ .........

1 2 3
4
5
62